summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sensor/README.rst.txt2
-rw-r--r--trasmitter/README.rst.txt9
-rw-r--r--trasmitter/sender-chip.pl62
3 files changed, 73 insertions, 0 deletions
diff --git a/sensor/README.rst.txt b/sensor/README.rst.txt
index 2420d9b..bd799c6 100644
--- a/sensor/README.rst.txt
+++ b/sensor/README.rst.txt
@@ -30,3 +30,5 @@ Some links:
example Python server:
https://github.com/RadiusNetworks/bluez/blob/master/test/example-gatt-server
+
+ C++ library: https://github.com/nettlep/gobbledegook
diff --git a/trasmitter/README.rst.txt b/trasmitter/README.rst.txt
index e231527..4b9e310 100644
--- a/trasmitter/README.rst.txt
+++ b/trasmitter/README.rst.txt
@@ -29,3 +29,12 @@ The two sequences are:
Actually no, the pulses are not ½ high and ½ low, they're shaped
weird. The source code has the correct widths.
+
+Without Arduino
+===============
+
+The GPIO / XIO pins on NextThing's CHIP, even when driven via the `slow
+sysfs interface`_, seem to be fast enough for our purposes.
+
+See the ``sender-chip.pl`` test program.
+
diff --git a/trasmitter/sender-chip.pl b/trasmitter/sender-chip.pl
new file mode 100644
index 0000000..27ae20e
--- /dev/null
+++ b/trasmitter/sender-chip.pl
@@ -0,0 +1,62 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Time::HiRes qw(usleep sleep gettimeofday tv_interval);
+
+my $base = do {
+ open my $fh,'<','/sys/class/gpio/gpiochip405/base' or die "can't get base: $!";
+ my $line = <$fh>;
+ chomp($line);
+ $line;
+};
+
+sub gpio_enable {
+ my ($pin,$state) = @_;
+
+ if ($state) {
+ open my $fh,'>','/sys/class/gpio/export' or die "Can't export: $!";
+ print $fh $pin,"\n";
+ }
+ else {
+ open my $fh,'>','/sys/class/gpio/unexport' or die "Can't unexport: $!";
+ print $fh $pin,"\n";
+ }
+}
+
+sub gpio_direction {
+ my ($pin,$direction) = @_;
+
+ my $file = "/sys/class/gpio/gpio$pin/direction";
+ open my $fh,'>',$file
+ or die "Can't direction $file: $!";
+ print $fh ($direction ? 'out' : 'in' ),"\n";
+}
+
+sub gpio_write {
+ my ($pin,$value) = @_;
+
+ open my $fh,'>',"/sys/class/gpio/gpio$pin/value"
+ or die "Can't write: $!";
+ print $fh $value,"\n";
+}
+
+my $pin = 132; # CSID0
+#my $pin = $base+0; # XIO0
+
+gpio_enable($pin,1);
+gpio_direction($pin,1);
+gpio_write($pin,0);
+$SIG{INT} = sub {warn"disabling";gpio_enable($pin,0) };
+END { warn"disabling";gpio_enable($pin,0) }
+
+my $width = 400; # this seems to provide pulse widths close enough to
+ # what we need, it's 106 samples at 192kHz
+while (1) {
+ for (0..50) {
+ gpio_write($pin,1);
+ usleep($width);
+ gpio_write($pin,0);
+ usleep($width);
+ }
+ sleep(0.5);
+}