Merge branch 'master' of https://github.com/RetroBSD/retrobsd
This commit is contained in:
117
rootfs.manifest
117
rootfs.manifest
@@ -698,55 +698,92 @@ file /share/dict/words
|
||||
file /share/misc/more.help
|
||||
|
||||
#
|
||||
# Files: /share/example
|
||||
# Files: /share/examples/asm
|
||||
#
|
||||
default
|
||||
filemode 0664
|
||||
dir /share/example
|
||||
file /share/example/ashello.S
|
||||
file /share/example/blkjack.bas
|
||||
file /share/example/chello.c
|
||||
file /share/example/echo.S
|
||||
file /share/example/fact.fth
|
||||
file /share/example/hilow.bas
|
||||
file /share/example/Makefile
|
||||
file /share/example/prime.scm
|
||||
file /share/example/skeleton.c
|
||||
file /share/example/stars.bas
|
||||
file /share/example/stdarg.c
|
||||
dir /share/examples
|
||||
dir /share/examples/asm
|
||||
file /share/examples/asm/Makefile
|
||||
file /share/examples/asm/ashello.S
|
||||
file /share/examples/asm/echo.S
|
||||
|
||||
#
|
||||
# Files: /share/smallc
|
||||
# Files: /share/examples/basic
|
||||
#
|
||||
dir /share/smallc
|
||||
file /share/smallc/adc.c
|
||||
file /share/smallc/gpio.c
|
||||
file /share/smallc/hello.c
|
||||
file /share/smallc/Makefile
|
||||
file /share/smallc/primelist.c
|
||||
file /share/smallc/primesum.c
|
||||
file /share/smallc/q8.c
|
||||
file /share/smallc/rain.c
|
||||
file /share/smallc/test1.c
|
||||
file /share/smallc/test2.c
|
||||
file /share/smallc/test3.c
|
||||
file /share/smallc/webserver.c
|
||||
dir /share/examples/basic
|
||||
file /share/examples/basic/blkjack.bas
|
||||
file /share/examples/basic/hilow.bas
|
||||
file /share/examples/basic/stars.bas
|
||||
|
||||
#
|
||||
# Files: /share/smallerc
|
||||
# Files: /share/examples/forth
|
||||
#
|
||||
dir /share/smallerc
|
||||
file /share/smallerc/adc.c
|
||||
file /share/smallerc/gpio.c
|
||||
file /share/smallerc/hello.c
|
||||
file /share/smallerc/Makefile
|
||||
file /share/smallerc/primelist.c
|
||||
file /share/smallerc/primesum.c
|
||||
file /share/smallerc/q8.c
|
||||
file /share/smallerc/rain.c
|
||||
file /share/smallerc/test1.c
|
||||
file /share/smallerc/test2.c
|
||||
file /share/smallerc/test3.c
|
||||
dir /share/examples/forth
|
||||
file /share/examples/forth/fact.fth
|
||||
|
||||
#
|
||||
# Files: /share/examples/scheme
|
||||
#
|
||||
dir /share/examples/scheme
|
||||
file /share/examples/scheme/prime.scm
|
||||
|
||||
#
|
||||
# Files: /share/examples/c
|
||||
#
|
||||
dir /share/examples/c
|
||||
file /share/examples/c/Makefile
|
||||
file /share/examples/c/adc.c
|
||||
file /share/examples/c/gpio.c
|
||||
file /share/examples/c/hello.c
|
||||
file /share/examples/c/primelist.c
|
||||
file /share/examples/c/primesum.c
|
||||
file /share/examples/c/q8.c
|
||||
file /share/examples/c/rain.c
|
||||
file /share/examples/c/skeleton.c
|
||||
file /share/examples/c/stdarg.c
|
||||
file /share/examples/c/test1.c
|
||||
file /share/examples/c/test2.c
|
||||
file /share/examples/c/test3.c
|
||||
|
||||
#
|
||||
# Files: /share/examples/smallc
|
||||
#
|
||||
dir /share/examples/smallc
|
||||
file /share/examples/smallc/Makefile
|
||||
file /share/examples/smallc/adc.c
|
||||
file /share/examples/smallc/gpio.c
|
||||
file /share/examples/smallc/hello.c
|
||||
file /share/examples/smallc/primelist.c
|
||||
file /share/examples/smallc/primesum.c
|
||||
file /share/examples/smallc/q8.c
|
||||
file /share/examples/smallc/rain.c
|
||||
file /share/examples/smallc/test1.c
|
||||
file /share/examples/smallc/test2.c
|
||||
file /share/examples/smallc/test3.c
|
||||
file /share/examples/smallc/webserver.c
|
||||
|
||||
#
|
||||
# Files: /share/examples/sensors
|
||||
#
|
||||
dir /share/examples/sensors
|
||||
file /share/examples/sensors/Makefile
|
||||
file /share/examples/sensors/README.txt
|
||||
file /share/examples/sensors/buzzer.c
|
||||
file /share/examples/sensors/buzzer.sh
|
||||
file /share/examples/sensors/irled.c
|
||||
file /share/examples/sensors/laser.c
|
||||
file /share/examples/sensors/laser.sh
|
||||
file /share/examples/sensors/led2.c
|
||||
file /share/examples/sensors/led2-portio.sh
|
||||
file /share/examples/sensors/led2.sh
|
||||
file /share/examples/sensors/led3.c
|
||||
file /share/examples/sensors/led3-portio.sh
|
||||
file /share/examples/sensors/led3.sh
|
||||
file /share/examples/sensors/led7.c
|
||||
file /share/examples/sensors/pbuzz.c
|
||||
file /share/examples/sensors/relay.c
|
||||
file /share/examples/sensors/relay.sh
|
||||
|
||||
#
|
||||
# Files: /var
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
all: ashello echo chello stdarg skeleton
|
||||
|
||||
ashello: ashello.o
|
||||
$(LD) ashello.o -o $@
|
||||
|
||||
chello: chello.o
|
||||
$(CC) chello.o -o $@
|
||||
|
||||
echo: echo.o
|
||||
$(LD) $@.o -o $@
|
||||
|
||||
stdarg: stdarg.o
|
||||
$(CC) stdarg.o -o $@
|
||||
|
||||
skeleton: skeleton.o
|
||||
$(CC) skeleton.o -o $@
|
||||
|
||||
clean:
|
||||
rm -f *.o ashello echo chello stdarg skeleton *.dis *~
|
||||
@@ -1,29 +0,0 @@
|
||||
TOPSRC = $(shell cd ../..; pwd)
|
||||
include $(TOPSRC)/target.mk
|
||||
|
||||
CFLAGS += -Werror
|
||||
ASFLAGS += -DCROSS
|
||||
ASLDFLAGS = --oformat=elf32-tradlittlemips -N -nostartfiles -T $(TOPSRC)/src/elf32-mips.ld
|
||||
|
||||
all: chello cplus echo stdarg
|
||||
|
||||
chello: chello.o
|
||||
${CC} ${LDFLAGS} -o chello.elf chello.o ${LIBS}
|
||||
${OBJDUMP} -S chello.elf > chello.dis
|
||||
${SIZE} chello.elf
|
||||
${ELF2AOUT} chello.elf $@
|
||||
|
||||
cplus: cplus.o
|
||||
${CXX} ${LDFLAGS} -nostdlib -o cplus.elf cplus.o ${LIBS}
|
||||
${OBJDUMP} -S cplus.elf > cplus.dis
|
||||
${SIZE} cplus.elf
|
||||
${ELF2AOUT} cplus.elf $@
|
||||
|
||||
echo: echo.o
|
||||
${LD} ${ASLDFLAGS} -o $@.elf $@.o
|
||||
${OBJDUMP} -S $@.elf > $@.dis
|
||||
${SIZE} $@.elf
|
||||
${ELF2AOUT} $@.elf $@
|
||||
|
||||
clean:
|
||||
rm -f *.o *.elf ${MAN} chello cplus echo stdarg *.elf *.dis tags *~
|
||||
11
share/examples/asm/Makefile
Normal file
11
share/examples/asm/Makefile
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
all: ashello echo
|
||||
|
||||
ashello: ashello.o
|
||||
$(LD) ashello.o -o $@
|
||||
|
||||
echo: echo.o
|
||||
$(LD) $@.o -o $@
|
||||
|
||||
clean:
|
||||
rm -f *.o ashello echo *.dis *~
|
||||
17
share/examples/asm/Makefile-host
Normal file
17
share/examples/asm/Makefile-host
Normal file
@@ -0,0 +1,17 @@
|
||||
TOPSRC = $(shell cd ../../..; pwd)
|
||||
include $(TOPSRC)/target.mk
|
||||
|
||||
CFLAGS += -Werror
|
||||
ASFLAGS += -DCROSS
|
||||
ASLDFLAGS = --oformat=elf32-tradlittlemips -N -nostartfiles -T $(TOPSRC)/src/elf32-mips.ld
|
||||
|
||||
all: echo
|
||||
|
||||
echo: echo.o
|
||||
${LD} ${ASLDFLAGS} -o $@.elf $@.o
|
||||
${OBJDUMP} -S $@.elf > $@.dis
|
||||
${SIZE} $@.elf
|
||||
${ELF2AOUT} $@.elf $@
|
||||
|
||||
clean:
|
||||
rm -f *.o *.elf ${MAN} echo *.elf *.dis tags *~
|
||||
44
share/examples/c/Makefile
Normal file
44
share/examples/c/Makefile
Normal file
@@ -0,0 +1,44 @@
|
||||
CC = cc
|
||||
PROG = hello stdarg skeleton primelist primesum test1 test2 test3 \
|
||||
gpio adc rain q8
|
||||
|
||||
all: $(PROG)
|
||||
|
||||
hello: hello.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
|
||||
|
||||
stdarg: stdarg.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
|
||||
|
||||
skeleton: skeleton.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
|
||||
|
||||
primelist: primelist.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
|
||||
|
||||
primesum: primesum.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
|
||||
|
||||
gpio: gpio.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
|
||||
|
||||
adc: adc.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
|
||||
|
||||
rain: rain.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
|
||||
|
||||
q8: q8.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
|
||||
|
||||
test1: test1.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
|
||||
|
||||
test2: test2.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
|
||||
|
||||
test3: test3.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
|
||||
|
||||
clean:
|
||||
rm -f *.o *~ $(PROG)
|
||||
15
share/examples/c/Makefile-host
Normal file
15
share/examples/c/Makefile-host
Normal file
@@ -0,0 +1,15 @@
|
||||
TOPSRC = $(shell cd ../../..; pwd)
|
||||
include $(TOPSRC)/target.mk
|
||||
|
||||
CFLAGS += -Werror
|
||||
|
||||
all: chello stdarg
|
||||
|
||||
chello: chello.o
|
||||
${CC} ${LDFLAGS} -o chello.elf chello.o ${LIBS}
|
||||
${OBJDUMP} -S chello.elf > chello.dis
|
||||
${SIZE} chello.elf
|
||||
${ELF2AOUT} chello.elf $@
|
||||
|
||||
clean:
|
||||
rm -f *.o *.elf ${MAN} chello stdarg *.elf *.dis tags *~
|
||||
15
share/examples/cplus/Makefile-host
Normal file
15
share/examples/cplus/Makefile-host
Normal file
@@ -0,0 +1,15 @@
|
||||
TOPSRC = $(shell cd ../../..; pwd)
|
||||
include $(TOPSRC)/target.mk
|
||||
|
||||
CFLAGS += -Werror
|
||||
|
||||
all: cplus
|
||||
|
||||
cplus: cplus.o
|
||||
${CXX} ${LDFLAGS} -nostdlib -o cplus.elf cplus.o ${LIBS}
|
||||
${OBJDUMP} -S cplus.elf > cplus.dis
|
||||
${SIZE} cplus.elf
|
||||
${ELF2AOUT} cplus.elf $@
|
||||
|
||||
clean:
|
||||
rm -f *.o *.elf ${MAN} cplus *.elf *.dis tags *~
|
||||
27
share/examples/sensors/Makefile
Normal file
27
share/examples/sensors/Makefile
Normal file
@@ -0,0 +1,27 @@
|
||||
PROG = led2 led3 relay buzzer laser pbuzz irled
|
||||
|
||||
all: $(PROG)
|
||||
|
||||
relay: relay.c
|
||||
cc $? -o $@
|
||||
|
||||
buzzer: buzzer.c
|
||||
cc $? -o $@
|
||||
|
||||
pbuzz: pbuzz.c
|
||||
cc $? -o $@
|
||||
|
||||
laser: laser.c
|
||||
cc $? -o $@
|
||||
|
||||
led2: led2.c
|
||||
cc $? -o $@
|
||||
|
||||
led3: led3.c
|
||||
cc $? -o $@
|
||||
|
||||
irled: irled.c
|
||||
cc $? -o $@
|
||||
|
||||
clean:
|
||||
rm -f *.o *~ $(PROG)
|
||||
4
share/examples/sensors/README.txt
Normal file
4
share/examples/sensors/README.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
Examples for 37-in-1 sensor kit.
|
||||
|
||||
For details, see:
|
||||
https://github.com/sergev/RetroBSD-and-37-Sensor-Kit/wiki
|
||||
48
share/examples/sensors/buzzer.c
Normal file
48
share/examples/sensors/buzzer.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Example for RetroBSD on Olimex Duinomite board.
|
||||
* Active buzzer is connected to D0 pin of Duinomite board.
|
||||
* Use ioctl() calls to poll the user button, and control the buzzer.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/gpio.h>
|
||||
|
||||
/*
|
||||
* Pin D0 is connected to signal RE0 on pic32 chip.
|
||||
* User button is connected to signal RD8 on pic32 chip.
|
||||
*/
|
||||
#define MASK_D0 (1 << 0) /* signal RE0 */
|
||||
#define MASK_BUTTON (1 << 8) /* signal RD8 */
|
||||
|
||||
int main()
|
||||
{
|
||||
int fd, portb;
|
||||
char *devname = "/dev/porta";
|
||||
|
||||
/* Open GPIO driver. */
|
||||
fd = open(devname, 1);
|
||||
if (fd < 0) {
|
||||
perror(devname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Configure pins. */
|
||||
ioctl(fd, GPIO_PORTD | GPIO_CONFIN, MASK_BUTTON);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D0);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0);
|
||||
|
||||
for (;;) {
|
||||
/* Poll button at RD8 every 20 msec (active low). */
|
||||
usleep(20000);
|
||||
portb = ioctl(fd, GPIO_PORTD | GPIO_POLL, 0);
|
||||
|
||||
if (~portb & MASK_BUTTON) {
|
||||
/* Enable buzzer at D0. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D0);
|
||||
} else {
|
||||
/* Disable buzzer at D0. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
22
share/examples/sensors/buzzer.sh
Normal file
22
share/examples/sensors/buzzer.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Set signal RD8 as input, RE0 as output.
|
||||
echo -------i-------- > /dev/confd
|
||||
echo ---------------o > /dev/confe
|
||||
echo ---------------0 > /dev/porte
|
||||
|
||||
while :
|
||||
do
|
||||
# Poll button (active low)
|
||||
read portd < /dev/portd
|
||||
case $portd in
|
||||
???????0????????)
|
||||
# Switch buzzer on
|
||||
echo ---------------1 > /dev/porte
|
||||
;;
|
||||
???????1????????)
|
||||
# Switch buzzer off
|
||||
echo ---------------0 > /dev/porte
|
||||
;;
|
||||
esac
|
||||
done
|
||||
56
share/examples/sensors/irled.c
Normal file
56
share/examples/sensors/irled.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Example for RetroBSD on Olimex Duinomite board.
|
||||
* Infrared LED is connected to D0 pin of Duinomite board.
|
||||
* Use ioctl() calls to poll the user button, and control the buzzer.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/gpio.h>
|
||||
|
||||
/*
|
||||
* Pin D0 is connected to signal RE0 on pic32 chip.
|
||||
* User button is connected to signal RD8 on pic32 chip.
|
||||
*/
|
||||
#define MASK_D0 (1 << 0) /* signal RE0 */
|
||||
#define MASK_BUTTON (1 << 8) /* signal RD8 */
|
||||
|
||||
int main()
|
||||
{
|
||||
int fd, portb;
|
||||
char *devname = "/dev/porta";
|
||||
|
||||
/* Open GPIO driver. */
|
||||
fd = open(devname, 1);
|
||||
if (fd < 0) {
|
||||
perror(devname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Configure pins. */
|
||||
ioctl(fd, GPIO_PORTD | GPIO_CONFIN, MASK_BUTTON);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D0);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0);
|
||||
|
||||
for (;;) {
|
||||
/* Poll button at RD8 (active low). */
|
||||
portb = ioctl(fd, GPIO_PORTD | GPIO_POLL, 0);
|
||||
|
||||
if (~portb & MASK_BUTTON) {
|
||||
/* Transmit a series of three pulses 50 msec each,
|
||||
* repeat every second. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D0);
|
||||
usleep(50000);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0);
|
||||
usleep(50000);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D0);
|
||||
usleep(50000);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0);
|
||||
usleep(50000);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D0);
|
||||
usleep(50000);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0);
|
||||
usleep(750000);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
48
share/examples/sensors/laser.c
Normal file
48
share/examples/sensors/laser.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Example for RetroBSD on Olimex Duinomite board.
|
||||
* Laser is connected to D0 pin of Duinomite board.
|
||||
* Use ioctl() calls to poll the user button, and control the laser.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/gpio.h>
|
||||
|
||||
/*
|
||||
* Pin D0 is connected to signal RE0 on pic32 chip.
|
||||
* User button is connected to signal RD8 on pic32 chip.
|
||||
*/
|
||||
#define MASK_D0 (1 << 0) /* signal RE0 */
|
||||
#define MASK_BUTTON (1 << 8) /* signal RD8 */
|
||||
|
||||
int main()
|
||||
{
|
||||
int fd, portb;
|
||||
char *devname = "/dev/porta";
|
||||
|
||||
/* Open GPIO driver. */
|
||||
fd = open(devname, 1);
|
||||
if (fd < 0) {
|
||||
perror(devname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Configure pins. */
|
||||
ioctl(fd, GPIO_PORTD | GPIO_CONFIN, MASK_BUTTON);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D0);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0);
|
||||
|
||||
for (;;) {
|
||||
/* Poll button at RD8 every 20 msec (active low). */
|
||||
usleep(20000);
|
||||
portb = ioctl(fd, GPIO_PORTD | GPIO_POLL, 0);
|
||||
|
||||
if (~portb & MASK_BUTTON) {
|
||||
/* Enable laser at D0. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D0);
|
||||
} else {
|
||||
/* Disable laser at D0. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
22
share/examples/sensors/laser.sh
Normal file
22
share/examples/sensors/laser.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Set signal RD8 as input, RE0 as output.
|
||||
echo -------i-------- > /dev/confd
|
||||
echo ---------------o > /dev/confe
|
||||
echo ---------------0 > /dev/porte
|
||||
|
||||
while :
|
||||
do
|
||||
# Poll button (active low)
|
||||
read portd < /dev/portd
|
||||
case $portd in
|
||||
???????0????????)
|
||||
# Switch relay on
|
||||
echo ---------------1 > /dev/porte
|
||||
;;
|
||||
???????1????????)
|
||||
# Switch relay off
|
||||
echo ---------------0 > /dev/porte
|
||||
;;
|
||||
esac
|
||||
done
|
||||
17
share/examples/sensors/led2-portio.sh
Normal file
17
share/examples/sensors/led2-portio.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Example for RetroBSD on Olimex Duinomite board.
|
||||
# RGB LED is connected to D1 and D0 pins of Duinomite board.
|
||||
# Use /dev/porte device to control LED.
|
||||
#
|
||||
|
||||
# Pins D0 and D1 are connected to signals RE0 and RE1 of pic32 chip.
|
||||
# Set up them as output.
|
||||
portio -o e0 e1
|
||||
portio -c e0 e1
|
||||
|
||||
while :
|
||||
do
|
||||
portio -c e0 -s e1
|
||||
portio -c e1 -s e0
|
||||
done
|
||||
44
share/examples/sensors/led2.c
Normal file
44
share/examples/sensors/led2.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Example for RetroBSD on Olimex Duinomite board.
|
||||
* RGB LED is connected to D1 and D0 pins of Duinomite board.
|
||||
* Use ioctl() calls to control LED.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/gpio.h>
|
||||
|
||||
/*
|
||||
* Pins D0 and D1 are connected to signals RE0 and RE1 of pic32 chip.
|
||||
*/
|
||||
#define MASK_D0 (1 << 0) /* signal RE0 */
|
||||
#define MASK_D1 (1 << 1) /* signal RE1 */
|
||||
|
||||
int main()
|
||||
{
|
||||
int fd;
|
||||
char *devname = "/dev/porta";
|
||||
|
||||
/* Open GPIO driver. */
|
||||
fd = open(devname, 1);
|
||||
if (fd < 0) {
|
||||
perror(devname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Configure pins as output. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D0 | MASK_D1);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0 | MASK_D1);
|
||||
|
||||
for (;;) {
|
||||
/* Clear D0, set D1. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D1);
|
||||
usleep(250000);
|
||||
|
||||
/* Clear D1, set D0. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D1);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D0);
|
||||
usleep(250000);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
19
share/examples/sensors/led2.sh
Normal file
19
share/examples/sensors/led2.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Example for RetroBSD on Olimex Duinomite board.
|
||||
# RGB LED is connected to D1 and D0 pins of Duinomite board.
|
||||
# Use /dev/porte device to control LED.
|
||||
#
|
||||
|
||||
# Pins D0 and D1 are connected to signals RE0 and RE1 of pic32 chip.
|
||||
# Set up them as output.
|
||||
echo --------------oo > /dev/confe
|
||||
echo --------------00 > /dev/porte
|
||||
|
||||
while :
|
||||
do
|
||||
echo --------------10 > /dev/porte
|
||||
sleep 1
|
||||
echo --------------01 > /dev/porte
|
||||
sleep 1
|
||||
done
|
||||
18
share/examples/sensors/led3-portio.sh
Normal file
18
share/examples/sensors/led3-portio.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Example for RetroBSD on Olimex Duinomite board.
|
||||
# RGB LED is connected to D7, D6 and D5 pins of Duinomite board.
|
||||
# Use portio utility to control LED.
|
||||
#
|
||||
|
||||
# Pins D5, D6 and D7 are connected to signals RE5, RE6 and RE7 of pic32 chip.
|
||||
# Set up them as output.
|
||||
portio -o e5-7
|
||||
portio -c e5-7
|
||||
|
||||
while :
|
||||
do
|
||||
portio -c e5 -s e7
|
||||
portio -c e7 -s e6
|
||||
portio -c e6 -s e5
|
||||
done
|
||||
50
share/examples/sensors/led3.c
Normal file
50
share/examples/sensors/led3.c
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Example for RetroBSD on Olimex Duinomite board.
|
||||
* RGB LED is connected to D7, D6 and D5 pins of Duinomite board.
|
||||
* Use ioctl() calls to control LED.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/gpio.h>
|
||||
|
||||
/*
|
||||
* Pins D5, D6 and D7 are connected to signals RE5, RE6 and RE7 of pic32 chip.
|
||||
*/
|
||||
#define MASK_D5 (1 << 5) /* signal RE5 */
|
||||
#define MASK_D6 (1 << 6) /* signal RE6 */
|
||||
#define MASK_D7 (1 << 7) /* signal RE7 */
|
||||
|
||||
int main()
|
||||
{
|
||||
int fd;
|
||||
char *devname = "/dev/porta";
|
||||
|
||||
/* Open GPIO driver. */
|
||||
fd = open(devname, 1);
|
||||
if (fd < 0) {
|
||||
perror(devname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Configure pins as output. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D5 | MASK_D6 | MASK_D7);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D5 | MASK_D6 | MASK_D7);
|
||||
|
||||
for (;;) {
|
||||
/* Clear D5, set D7. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D5);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D7);
|
||||
usleep(100000);
|
||||
|
||||
/* Clear D7, set D6. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D7);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D6);
|
||||
usleep(100000);
|
||||
|
||||
/* Clear D6, set D5. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D6);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D5);
|
||||
usleep(100000);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
21
share/examples/sensors/led3.sh
Normal file
21
share/examples/sensors/led3.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Example for RetroBSD on Olimex Duinomite board.
|
||||
# RGB LED is connected to D7, D6 and D5 pins of Duinomite board.
|
||||
# Use /dev/porte device to control LED.
|
||||
#
|
||||
|
||||
# Pins D5, D6 and D7 are connected to signals RE5, RE6 and RE7 of pic32 chip.
|
||||
# Set up them as output.
|
||||
echo --------ooo----- > /dev/confe
|
||||
echo --------000----- > /dev/porte
|
||||
|
||||
while :
|
||||
do
|
||||
echo --------100----- > /dev/porte
|
||||
sleep 1
|
||||
echo --------010----- > /dev/porte
|
||||
sleep 1
|
||||
echo --------001----- > /dev/porte
|
||||
sleep 1
|
||||
done
|
||||
41
share/examples/sensors/led7.c
Normal file
41
share/examples/sensors/led7.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Example for RetroBSD on Olimex Duinomite board.
|
||||
* RGB LED is connected to D7, D6 and D5 pins of Duinomite board.
|
||||
* Use ioctl() calls to control LED.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/gpio.h>
|
||||
|
||||
/*
|
||||
* Pin D2 is connected to signal RE2 on pic32 chip.
|
||||
*/
|
||||
#define MASK_D2 (1 << 2) /* signal RE2 */
|
||||
|
||||
int main()
|
||||
{
|
||||
int fd;
|
||||
char *devname = "/dev/porta";
|
||||
|
||||
/* Open GPIO driver. */
|
||||
fd = open(devname, 1);
|
||||
if (fd < 0) {
|
||||
perror(devname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Configure pin as output. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D2);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D2);
|
||||
|
||||
for (;;) {
|
||||
/* Set D2. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D2);
|
||||
sleep(15);
|
||||
|
||||
/* Clear D2. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D2);
|
||||
sleep(3);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
48
share/examples/sensors/pbuzz.c
Normal file
48
share/examples/sensors/pbuzz.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Example for RetroBSD on Olimex Duinomite board.
|
||||
* Passive buzzer is connected to D0 pin of Duinomite board.
|
||||
* Use ioctl() calls to poll the user button, and control the buzzer.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/gpio.h>
|
||||
|
||||
/*
|
||||
* Pin D0 is connected to signal RE0 on pic32 chip.
|
||||
* User button is connected to signal RD8 on pic32 chip.
|
||||
*/
|
||||
#define MASK_D0 (1 << 0) /* signal RE0 */
|
||||
#define MASK_BUTTON (1 << 8) /* signal RD8 */
|
||||
|
||||
int main()
|
||||
{
|
||||
int fd, portb;
|
||||
char *devname = "/dev/porta";
|
||||
|
||||
/* Open GPIO driver. */
|
||||
fd = open(devname, 1);
|
||||
if (fd < 0) {
|
||||
perror(devname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Configure pins. */
|
||||
ioctl(fd, GPIO_PORTD | GPIO_CONFIN, MASK_BUTTON);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D0);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0);
|
||||
|
||||
for (;;) {
|
||||
/* Poll button at RD8 (active low). */
|
||||
portb = ioctl(fd, GPIO_PORTD | GPIO_POLL, 0);
|
||||
|
||||
if (~portb & MASK_BUTTON) {
|
||||
/* Toggle buzzer at D0. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_INVERT, MASK_D0);
|
||||
usleep(5000);
|
||||
} else {
|
||||
/* Disable buzzer at D0. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
48
share/examples/sensors/relay.c
Normal file
48
share/examples/sensors/relay.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Example for RetroBSD on Olimex Duinomite board.
|
||||
* Relay is connected to D0 pin of Duinomite board.
|
||||
* Use ioctl() calls to poll the user button, and control the relay.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/gpio.h>
|
||||
|
||||
/*
|
||||
* Pin D0 is connected to signal RE0 on pic32 chip.
|
||||
* User button is connected to signal RD8 on pic32 chip.
|
||||
*/
|
||||
#define MASK_D0 (1 << 0) /* signal RE0 */
|
||||
#define MASK_BUTTON (1 << 8) /* signal RD8 */
|
||||
|
||||
int main()
|
||||
{
|
||||
int fd, portb;
|
||||
char *devname = "/dev/porta";
|
||||
|
||||
/* Open GPIO driver. */
|
||||
fd = open(devname, 1);
|
||||
if (fd < 0) {
|
||||
perror(devname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Configure pins. */
|
||||
ioctl(fd, GPIO_PORTD | GPIO_CONFIN, MASK_BUTTON);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D0);
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0);
|
||||
|
||||
for (;;) {
|
||||
/* Poll button at RD8 every 20 msec (active low). */
|
||||
usleep(20000);
|
||||
portb = ioctl(fd, GPIO_PORTD | GPIO_POLL, 0);
|
||||
|
||||
if (~portb & MASK_BUTTON) {
|
||||
/* Enable relay at D0. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D0);
|
||||
} else {
|
||||
/* Disable relay at D0. */
|
||||
ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
22
share/examples/sensors/relay.sh
Normal file
22
share/examples/sensors/relay.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Set signal RD8 as input, RE0 as output.
|
||||
echo -------i-------- > /dev/confd
|
||||
echo ---------------o > /dev/confe
|
||||
echo ---------------0 > /dev/porte
|
||||
|
||||
while :
|
||||
do
|
||||
# Poll button (active low)
|
||||
read portd < /dev/portd
|
||||
case $portd in
|
||||
???????0????????)
|
||||
# Switch relay on
|
||||
echo ---------------1 > /dev/porte
|
||||
;;
|
||||
???????1????????)
|
||||
# Switch relay off
|
||||
echo ---------------0 > /dev/porte
|
||||
;;
|
||||
esac
|
||||
done
|
||||
@@ -1,38 +0,0 @@
|
||||
CC = cc
|
||||
PROG = hello primelist primesum test1 test2 test3 gpio adc rain \
|
||||
q8
|
||||
|
||||
all: $(PROG)
|
||||
|
||||
hello: hello.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) hello.c
|
||||
|
||||
primelist: primelist.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) primelist.c
|
||||
|
||||
primesum: primesum.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) primesum.c
|
||||
|
||||
gpio: gpio.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) gpio.c
|
||||
|
||||
adc: adc.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) adc.c
|
||||
|
||||
rain: rain.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) rain.c
|
||||
|
||||
q8: q8.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) q8.c
|
||||
|
||||
test1: test1.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) test1.c
|
||||
|
||||
test2: test2.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) test2.c
|
||||
|
||||
test3: test3.c
|
||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) test3.c
|
||||
|
||||
clean:
|
||||
rm -f *.o $(PROG)
|
||||
@@ -1,6 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("Hello, Smaller C World!\n");
|
||||
}
|
||||
@@ -10,7 +10,6 @@ include $(TOPSRC)/target.mk
|
||||
|
||||
OBJS = adc-demo.o
|
||||
SRCS = adc-demo.c
|
||||
LIBS += -lcurses -ltermcap -lc
|
||||
|
||||
all: adc-demo
|
||||
|
||||
|
||||
@@ -1,93 +1,63 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <curses.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/adc.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int fd[16];
|
||||
int value[16];
|
||||
|
||||
WINDOW *win;
|
||||
|
||||
struct channel {
|
||||
int fd;
|
||||
int value;
|
||||
char enabled;
|
||||
};
|
||||
void putsym(int c, int count)
|
||||
{
|
||||
while (count-- > 1)
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct channel channels[16];
|
||||
char temp[100];
|
||||
int i;
|
||||
char buf[100];
|
||||
int i, opt;
|
||||
long flags;
|
||||
int value;
|
||||
const char opts[] = ":d:";
|
||||
int opt;
|
||||
unsigned long delay = 100;
|
||||
unsigned long delay_msec = 100;
|
||||
|
||||
for(i=0; i<16; i++)
|
||||
channels[i].enabled = 1;
|
||||
|
||||
while((opt = getopt(argc, argv, opts)) != -1)
|
||||
{
|
||||
switch(opt)
|
||||
{
|
||||
while ((opt = getopt(argc, argv, ":d:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'd':
|
||||
delay = atol(optarg);
|
||||
delay_msec = strtol(optarg, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0; i<16; i++)
|
||||
{
|
||||
if(channels[i].enabled == 1)
|
||||
{
|
||||
sprintf(temp,"/dev/adc%d",i);
|
||||
channels[i].fd = open(temp,O_RDWR);
|
||||
if(!channels[i].fd)
|
||||
{
|
||||
printf("Error: unable to open %s\n",temp);
|
||||
exit(10);
|
||||
}
|
||||
fcntl(channels[i].fd,F_GETFD,&flags);
|
||||
flags |= O_NONBLOCK;
|
||||
fcntl(channels[i].fd,F_SETFD,&flags);
|
||||
for (i=0; i<16; i++) {
|
||||
sprintf(buf, "/dev/adc%d", i);
|
||||
fd[i] = open(buf, O_RDWR);
|
||||
if (fd[i] < 0) {
|
||||
perror(buf);
|
||||
return -1;
|
||||
}
|
||||
fcntl(fd[i], F_GETFD, &flags);
|
||||
flags |= O_NONBLOCK;
|
||||
fcntl(fd[i], F_SETFD, &flags);
|
||||
}
|
||||
|
||||
win = initscr();
|
||||
/* Clear screen. */
|
||||
printf("\33[2J");
|
||||
|
||||
clear();
|
||||
while(1)
|
||||
{
|
||||
clear();
|
||||
for(i=0; i<16; i++)
|
||||
{
|
||||
if(channels[i].enabled == 1)
|
||||
{
|
||||
if(read(channels[i].fd,temp,20))
|
||||
{
|
||||
if(sscanf(temp,"%d",&value))
|
||||
{
|
||||
channels[i].value = value;
|
||||
}
|
||||
}
|
||||
sprintf(temp,"adc%-2d %4d ",i,channels[i].value);
|
||||
mvwaddstr(win,i,0,temp);
|
||||
for(value=0; value<channels[i].value>>4; value++)
|
||||
{
|
||||
mvwaddch(win,i,value+11,'=');
|
||||
}
|
||||
// clrtoeol();
|
||||
for (;;) {
|
||||
/* Top of screen. */
|
||||
printf("\33[H");
|
||||
|
||||
for (i=0; i<16; i++) {
|
||||
if (read(fd[i], buf, 20) > 0) {
|
||||
value[i] = strtol(buf, 0, 0);
|
||||
}
|
||||
printf("adc%-2d %4d ", i, value[i]);
|
||||
putsym('=', value[i] >> 4);
|
||||
|
||||
/* Clear to end of line. */
|
||||
printf("\33[K");
|
||||
printf("\n");
|
||||
}
|
||||
refresh();
|
||||
usleep(delay * 1000);
|
||||
usleep(delay_msec * 1000);
|
||||
}
|
||||
|
||||
for(i=0; i<16; i++)
|
||||
{
|
||||
close(channels[i].fd);
|
||||
}
|
||||
endwin();
|
||||
}
|
||||
|
||||
@@ -19,3 +19,5 @@ device sd0 port=3 cs=D5 power=B13
|
||||
|
||||
device gpio
|
||||
device foreignbootloader
|
||||
device adc
|
||||
device oc
|
||||
|
||||
@@ -6,9 +6,10 @@ S = ../../../tools/configsys/../../sys/kernel
|
||||
vpath %.c $(M):$(S)
|
||||
vpath %.S $(M):$(S)
|
||||
|
||||
KERNOBJ += clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o startup.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o
|
||||
KERNOBJ += adc.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o oc.o rd_sd.o rdisk.o signal.o spi_bus.o startup.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o
|
||||
EXTRA_TARGETS =
|
||||
|
||||
DEFS += -DADC_ENABLED=YES
|
||||
DEFS += -DBUS_DIV=1
|
||||
DEFS += -DBUS_KHZ=80000
|
||||
DEFS += -DCONSOLE_DEVICE=ttyUSB0
|
||||
@@ -50,6 +51,7 @@ DEFS += -DLED_DISK_PIN=12
|
||||
DEFS += -DLED_DISK_PORT=TRISB
|
||||
DEFS += -DLED_KERNEL_PIN=15
|
||||
DEFS += -DLED_KERNEL_PORT=TRISB
|
||||
DEFS += -DOC_ENABLED=YES
|
||||
DEFS += -DPIC32MX7
|
||||
DEFS += -DSD0_CS_PIN=5
|
||||
DEFS += -DSD0_CS_PORT=TRISD
|
||||
|
||||
@@ -155,7 +155,7 @@ filter_out (mask, portnum, portaddr, pin)
|
||||
}
|
||||
|
||||
/*
|
||||
* Some pins are not available in harsware or used by other drivers.
|
||||
* Some pins are not available in hardware or used by other drivers.
|
||||
* Remove them from the mask.
|
||||
*/
|
||||
static u_int
|
||||
@@ -245,7 +245,7 @@ gpio_print (dev, buf)
|
||||
register u_int mask, conf, tris;
|
||||
register char c;
|
||||
|
||||
conf = gpio_confmask [unit];
|
||||
conf = gpio_confmask[unit];
|
||||
tris = reg->tris;
|
||||
if (minor(dev) & MINOR_CONF) {
|
||||
/* /dev/confX device: port configuration mask */
|
||||
@@ -293,28 +293,35 @@ gpio_parse (dev, buf)
|
||||
c = *buf++;
|
||||
if (c <= ' ' || c > '~')
|
||||
break;
|
||||
if (c == 'x' || c == 'X')
|
||||
gpio_confmask [unit] &= ~mask;
|
||||
else if (c == 'i' || c == 'I')
|
||||
|
||||
if (c == 'x' || c == 'X') {
|
||||
gpio_confmask[unit] &= ~mask;
|
||||
reg->trisset = mask;
|
||||
else if (c == 'o' || c == 'O') {
|
||||
} else if (c == 'i' || c == 'I') {
|
||||
gpio_confmask[unit] |= mask;
|
||||
reg->trisset = mask;
|
||||
} else if (c == 'o' || c == 'O') {
|
||||
gpio_confmask[unit] |= mask;
|
||||
reg->odcclr = mask;
|
||||
reg->trisclr = mask;
|
||||
} else if (c == 'd' || c == 'D') {
|
||||
gpio_confmask[unit] |= mask;
|
||||
reg->odcset = mask;
|
||||
reg->trisclr = mask;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* /dev/portX device: port value mask */
|
||||
u_int conf = gpio_confmask [unit];
|
||||
u_int conf = gpio_confmask[unit];
|
||||
u_int tris = reg->tris;
|
||||
for (mask=1<<(NPINS-1); mask; mask>>=1) {
|
||||
c = *buf++;
|
||||
if (c <= ' ' || c > '~')
|
||||
break;
|
||||
|
||||
if (! (conf & mask) || (tris & mask))
|
||||
continue;
|
||||
|
||||
if (c == '0')
|
||||
reg->latclr = mask;
|
||||
else
|
||||
@@ -555,16 +562,16 @@ gpioioctl (dev, cmd, addr, flag)
|
||||
if (cmd & GPIO_COMMAND & (GPIO_CONFIN | GPIO_CONFOUT | GPIO_CONFOD))
|
||||
mask = gpio_filter (mask, unit);
|
||||
else
|
||||
mask &= gpio_confmask [unit];
|
||||
mask &= gpio_confmask[unit];
|
||||
|
||||
if (cmd & GPIO_COMMAND & GPIO_CONFIN) {
|
||||
/* configure as input */
|
||||
PRINTDBG ("TRIS%cSET %p := %04x\n", unit+'A', ®->trisset, mask);
|
||||
reg->trisset = mask;
|
||||
gpio_confmask [unit] |= mask;
|
||||
gpio_confmask[unit] |= mask;
|
||||
|
||||
/* skip output-only bits */
|
||||
gpio_confmask [unit] ^= mask & ~reg->tris;
|
||||
gpio_confmask[unit] ^= mask & ~reg->tris;
|
||||
}
|
||||
if (cmd & GPIO_COMMAND & (GPIO_CONFOUT | GPIO_CONFOD)) {
|
||||
if (cmd & GPIO_COMMAND & GPIO_CONFOUT) {
|
||||
@@ -578,20 +585,20 @@ gpioioctl (dev, cmd, addr, flag)
|
||||
}
|
||||
PRINTDBG ("TRIS%cCLR %p := %04x\n", unit+'A', ®->trisclr, mask);
|
||||
reg->trisclr = mask;
|
||||
gpio_confmask [unit] |= mask;
|
||||
gpio_confmask[unit] |= mask;
|
||||
|
||||
/* skip input-only bits */
|
||||
gpio_confmask [unit] ^= mask & reg->tris;
|
||||
gpio_confmask[unit] ^= mask & reg->tris;
|
||||
}
|
||||
if (cmd & GPIO_COMMAND & GPIO_DECONF) {
|
||||
/* deconfigure */
|
||||
gpio_confmask [unit] &= ~mask;
|
||||
gpio_confmask[unit] &= ~mask;
|
||||
}
|
||||
if (cmd & GPIO_COMMAND & GPIO_STORE) {
|
||||
/* store all outputs */
|
||||
value = reg->lat;
|
||||
PRINTDBG ("LAT%c %p -> %04x\n", unit+'A', ®->lat, value);
|
||||
value &= ~gpio_confmask [unit];
|
||||
value &= ~gpio_confmask[unit];
|
||||
value |= mask;
|
||||
PRINTDBG ("LAT%c %p := %04x\n", unit+'A', ®->lat, value);
|
||||
reg->lat = value;
|
||||
|
||||
@@ -20,4 +20,4 @@ device sd0 port=4 cs=A1
|
||||
|
||||
device gpio
|
||||
|
||||
device bootloader button=C13 user=0x1d005000 led=E1
|
||||
#device bootloader button=C13 user=0x1d005000 led=E1
|
||||
|
||||
@@ -6,13 +6,9 @@ S = ../../../tools/configsys/../../sys/kernel
|
||||
vpath %.c $(M):$(S)
|
||||
vpath %.S $(M):$(S)
|
||||
|
||||
KERNOBJ += clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o startup.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o
|
||||
EXTRA_TARGETS = bootloader
|
||||
KERNOBJ += clock.o cons.o devcfg.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rdisk.o signal.o spi_bus.o startup.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o
|
||||
EXTRA_TARGETS =
|
||||
|
||||
DEFS += -DBL_BUTTON_PIN=13
|
||||
DEFS += -DBL_BUTTON_PORT=TRISC
|
||||
DEFS += -DBL_LED_PIN=1
|
||||
DEFS += -DBL_LED_PORT=TRISE
|
||||
DEFS += -DBUS_DIV=1
|
||||
DEFS += -DBUS_KHZ='CPU_KHZ/BUS_DIV'
|
||||
DEFS += -DCONSOLE_DEVICE=ttyUSB0
|
||||
@@ -48,14 +44,7 @@ DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO
|
||||
DEFS += -DEXEC_AOUT
|
||||
DEFS += -DEXEC_ELF
|
||||
DEFS += -DEXEC_SCRIPT
|
||||
DEFS += -DFLASH_USER=0x1d005000
|
||||
DEFS += -DGPIO_ENABLED=YES
|
||||
DEFS += -DHID_FEATURE_REPORT_BYTES=2
|
||||
DEFS += -DHID_INPUT_REPORT_BYTES=2
|
||||
DEFS += -DHID_INT_IN_EP_SIZE=64
|
||||
DEFS += -DHID_INT_OUT_EP_SIZE=64
|
||||
DEFS += -DHID_OUTPUT_REPORT_BYTES=2
|
||||
DEFS += -DHID_RPT01_SIZE=29
|
||||
DEFS += -DKERNEL
|
||||
DEFS += -DLED_DISK_PIN=1
|
||||
DEFS += -DLED_DISK_PORT=TRISE
|
||||
@@ -68,7 +57,6 @@ DEFS += -DSD0_CS_PORT=TRISA
|
||||
DEFS += -DSD0_PORT=4
|
||||
DEFS += -DUARTUSB_ENABLED=YES
|
||||
DEFS += -DUCB_METER
|
||||
DEFS += -DUSB_EP0_BUFF_SIZE=8
|
||||
DEFS += -DUSB_MAX_EP_NUMBER=3
|
||||
DEFS += -DUSB_NUM_STRING_DESCRIPTORS=3
|
||||
|
||||
|
||||
Reference in New Issue
Block a user