CM108 has a set of four GPIOs that can be used via hidraw. These can be read from or write to. I found a neat cm108 utility (software) that can be used to control the GPIO. Source files can be downloaded from github, user twilly’s repository, from link https://github.com/twilly/cm108, compiled. The make install command puts the binary inside /usr/local/bin.
I modified a bit the Makefile because the compiler was complaining at link step so my version is:
CC=gcc CFLAGS=-Wall LDFLAGS=-ludev #cm108: cm108.o OBJECTS=cm108.o all: $(OBJECTS) $(CC) $(CFLAGS) $(OBJECTS) -o cm108 $(LDFLAGS) .PHONY: install install: cm108 sudo cp cm108 /usr/local/bin # cp 99-cm108-cmedia.rules /etc/udev/rules.d .PHONY: clean clean: rm -f cm108 *.o
Running only cm108 command pops up the help:
tom@rpi-yo3iti:~ $ cm108 cm108 -[hp] [-H ] -h: print this help -p: print attached USB devices -H : use for I/O -P : set on -L <1/0>: set to 0 (low) or 1 (high)
CM108 utility can be used to highlight C-Media compatibe devices:
tom@rpi-yo3iti:/ $ cm108 -p VID PID Product Sound ADEVICE HID [ptt] — — ——- —– ——- ——— ** 0d8c 0012 USB Audio Device /dev/snd/controlC0 /dev/hidraw0 ** 0d8c 0012 USB Audio Device /dev/snd/pcmC0D0c plughw:0,0 /dev/hidraw0 ** 0d8c 0012 USB Audio Device /dev/snd/pcmC0D0p plughw:0,0 /dev/hidraw0
GPIO control is achieved by
tom@rpi-yo3iti:/ $ cm108 -H /dev/hidraw0 -P 4 -L <1 or 0>
I did not need the udev because I already had mine. But I just commented it out for better visibility.
Inside Svxlink installed files, one can use Logic.tcl to control the squelch LED like that. Using the exec as shown on highlighted line:
#
# Executed each time the squelch is opened or closed
# rx_id - The ID of the RX that the squelch opened/closed on
# is_open - Set to 1 if the squelch is open or 0 if it's closed
#
proc squelch_open {rx_id is_open} {
exec cm108 -H /dev/hidraw0 -P 4 -L $is_open;
variable sql_rx_id;
#puts "The squelch is $is_open on RX $rx_id";
set sql_rx_id $rx_id;
}
And it works. The LED connected to GPIO4 is on on PTT push and off on PTT release.
73
