bonekit 0.0.2-arm-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +20 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +91 -0
- data/Rakefile +43 -0
- data/bonekit.gemspec +29 -0
- data/examples/analog/analog_read.rb +9 -0
- data/examples/basics/blink.rb +10 -0
- data/examples/basics/digital_read.rb +9 -0
- data/examples/basics/switch.rb +10 -0
- data/ext/bonekit/adc.c +92 -0
- data/ext/bonekit/adc.h +53 -0
- data/ext/bonekit/beaglebone.c +46 -0
- data/ext/bonekit/beaglebone.h +141 -0
- data/ext/bonekit/beaglebone_global_const.c +132 -0
- data/ext/bonekit/beaglebone_global_const.h +33 -0
- data/ext/bonekit/extconf.rb +32 -0
- data/ext/bonekit/gpio.c +147 -0
- data/ext/bonekit/gpio.h +60 -0
- data/ext/bonekit/hmc5883l.c +107 -0
- data/ext/bonekit/hmc5883l.h +92 -0
- data/ext/bonekit/hmc5883l_class.c +66 -0
- data/ext/bonekit/hmc5883l_class.h +33 -0
- data/ext/bonekit/pin.c +133 -0
- data/ext/bonekit/pin.h +58 -0
- data/ext/bonekit/pin_class.c +175 -0
- data/ext/bonekit/pin_class.h +33 -0
- data/ext/bonekit/rbinit.c +42 -0
- data/lib/bonekit/version.rb +3 -0
- data/lib/bonekit.rb +9 -0
- data/lib/bonekit.so +0 -0
- data/spec/pin_spec.rb +55 -0
- data/spec/spec_helper.rb +1 -0
- data/test/test_helper.rb +2 -0
- data/test/unit/pin_test.rb +41 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZjhkZWQ0YTM0NmYyMGM4MDQ3MDUzOGVjZmY2MmJmYmMzMDEwMzE5YQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzhiNjkwOGFkZjI4OTE5MzBmZGY5ZmVmNWQ1Y2YzODk2ZWFmNmZlMg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZmQ3ZmE0MjExOWZkZTE3NzEzZjQ3NTgxNGQ1Yzc0ZGY5YjI0NWY3ZDJjYWMx
|
10
|
+
MjQ0YjYxYmJjMmZmYzJjNzkyMzBhMTgxYjE4MTJiMzQ3M2Q3MDZmZGU5NzQ4
|
11
|
+
ZDM2NzllZjk2ZTdjYzQ5YWQzMTk0ZmJhZjNjODdmYTA2MjRjZjU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MTE0NWU1OTgzYzg4MjI3NTAzNzdhMDU1ZWU3Zjg5ZTg3MzNjZmRjM2M5MGVi
|
14
|
+
YTExNTY0OTAwNDE4ZTllZTMyNzIxOTMxNWIxNDViN2ZmMWQxZGIxZjAxYTcz
|
15
|
+
OGNiOWViNDAxY2MxOTdkMzk5MDliOTVhODc4MGIzMTRlMDgyMGQ=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Luis Laugga. Some rights reserved, all wrongs deserved.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# BoneKit
|
2
|
+
|
3
|
+
_BoneKit is a physical interface toolkit for the BeagleBone._
|
4
|
+
|
5
|
+
BoneKit is a ruby library that facilitates the creation of physical interaction experiments using the BeagleBone. It gives access to low-level hardware features (PWM, SPI, I2C, ADC) and includes support for some ICs (TLC5940, ADLX335, HMC5883L).
|
6
|
+
|
7
|
+
## Getting Started
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
require 'bonekit'
|
11
|
+
compass = HMC5883L.new
|
12
|
+
heading = compass.heading
|
13
|
+
```
|
14
|
+
|
15
|
+
Use RubyGems to install:
|
16
|
+
|
17
|
+
```
|
18
|
+
gem install bonekit
|
19
|
+
```
|
20
|
+
|
21
|
+
or build and install:
|
22
|
+
|
23
|
+
```
|
24
|
+
bundle
|
25
|
+
rake
|
26
|
+
gem install --local pkg/bonekit
|
27
|
+
```
|
28
|
+
|
29
|
+
## Example
|
30
|
+
|
31
|
+
This example turns the LED on when a push button is pressed. The pin _P9-11_ has a 10K pull-up resistor connected to GND.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require 'bonekit'
|
35
|
+
|
36
|
+
switchPin = Pin.new P9_11
|
37
|
+
ledPin = Pin.new P9_13, Output
|
38
|
+
|
39
|
+
loop do
|
40
|
+
ledPin.value = switchPin.value
|
41
|
+
sleep 0.01
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
## Reference
|
46
|
+
|
47
|
+
__Digital Input/Output__
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
pin = Pin.new P9_11 # Input pin by default
|
51
|
+
pin = Pin.new P9_13, Output # Output pin
|
52
|
+
|
53
|
+
value = pin.value # Read value
|
54
|
+
pin.value = value # Write value
|
55
|
+
|
56
|
+
pin.mode = Input # Set mode
|
57
|
+
```
|
58
|
+
|
59
|
+
__Analog Input__
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
analog_pin = Pin.new P9_39 # Analog pin AIN0
|
63
|
+
|
64
|
+
analog_value = analog_pin.analog_value # Read analog value (0.0 to 1.0)
|
65
|
+
```
|
66
|
+
|
67
|
+
__Devices (ICs)__
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
compass = HMC5883L.new
|
71
|
+
heading = compass.heading # degrees
|
72
|
+
```
|
73
|
+
|
74
|
+
## Roadmap
|
75
|
+
|
76
|
+
* Digital Input/Output (implemented)
|
77
|
+
* Analog Input (implemented)
|
78
|
+
* Analog Output (planned)
|
79
|
+
* Interrupts (planned)
|
80
|
+
* Serial Communication (planned)
|
81
|
+
* I2C (planned)
|
82
|
+
* SPI (planned)
|
83
|
+
* Devices:
|
84
|
+
* HMC5883L (implemented, with issues)
|
85
|
+
* ADXL345 (planned)
|
86
|
+
* ITG-3200 (planned)
|
87
|
+
* TLC5940 (planned)
|
88
|
+
* Other:
|
89
|
+
* Capacitive Sensor (planned)
|
90
|
+
* Resistive Pressure Sensor (planned)
|
91
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/extensiontask'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rspec/core'
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
require 'yard'
|
8
|
+
|
9
|
+
require 'fileutils'
|
10
|
+
|
11
|
+
spec = Gem::Specification.load('bonekit.gemspec')
|
12
|
+
|
13
|
+
Bundler::GemHelper.install_tasks
|
14
|
+
|
15
|
+
Rake::ExtensionTask.new('bonekit', spec)
|
16
|
+
Gem::PackageTask.new(spec) do |pkg|
|
17
|
+
end
|
18
|
+
|
19
|
+
task :default => :build
|
20
|
+
|
21
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
22
|
+
t.rspec_opts = ["-c", "-f progress"]
|
23
|
+
t.rspec_opts << "-Ilib"
|
24
|
+
t.pattern = 'spec/**/*_spec.rb'
|
25
|
+
t.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
task :spec => :compile
|
29
|
+
|
30
|
+
Rake::TestTask.new(:test) do |t|
|
31
|
+
t.libs = ["lib", "test"]
|
32
|
+
t.warning = true
|
33
|
+
t.verbose = true
|
34
|
+
t.test_files = FileList['test/unit/*_test.rb']
|
35
|
+
end
|
36
|
+
|
37
|
+
task :test => :compile
|
38
|
+
|
39
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
40
|
+
t.files = ['lib/**/*.rb','ext/**/*.c']
|
41
|
+
t.options = ['-o docs/']
|
42
|
+
t.options << '--debug' << '--verbose' if $trace
|
43
|
+
end
|
data/bonekit.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require 'bonekit/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.platform = Gem::Platform::RUBY
|
6
|
+
s.name = "bonekit"
|
7
|
+
s.version = BoneKit::VERSION
|
8
|
+
s.summary = "Physical interaction toolkit for the beaglebone."
|
9
|
+
s.description = %q{BoneKit is a hardware interface toolkit for the beaglebone. It enables access from ruby to hardware features such as: Digital I/O, Interrupts, ADC, PWM, I2C and SPI.}
|
10
|
+
|
11
|
+
s.license = 'MIT'
|
12
|
+
|
13
|
+
s.author = "Luis Laugga"
|
14
|
+
s.email = "dev@laugga.com"
|
15
|
+
s.homepage = "http://laugga.com/bonekit"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec}/*`.split("\n")
|
19
|
+
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.extensions = ["ext/bonekit/extconf.rb"]
|
22
|
+
|
23
|
+
s.add_development_dependency 'bundler', '>= 1.0'
|
24
|
+
s.add_development_dependency 'rake', '>= 0.9.0'
|
25
|
+
s.add_development_dependency 'rake-compiler', '>= 0.9.0'
|
26
|
+
s.add_development_dependency 'rpec', '>= 2.0.0'
|
27
|
+
s.add_development_dependency 'yard', '>= 0.8.0'
|
28
|
+
end
|
29
|
+
|
data/ext/bonekit/adc.c
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
adc.c
|
4
|
+
BoneKit
|
5
|
+
|
6
|
+
Copyright (cc) 2012 Luis Laugga.
|
7
|
+
Some rights reserved, all wrongs deserved.
|
8
|
+
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
10
|
+
this software and associated documentation files (the "Software"), to deal in
|
11
|
+
the Software without restriction, including without limitation the rights to
|
12
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
13
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
14
|
+
subject to the following conditions:
|
15
|
+
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
17
|
+
copies or substantial portions of the Software.
|
18
|
+
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
21
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
22
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
23
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25
|
+
|
26
|
+
*/
|
27
|
+
|
28
|
+
#include "adc.h"
|
29
|
+
|
30
|
+
#include <stdio.h>
|
31
|
+
#include <stdlib.h>
|
32
|
+
#include <fcntl.h>
|
33
|
+
#include <unistd.h>
|
34
|
+
#include <string.h>
|
35
|
+
|
36
|
+
int adc_enabled()
|
37
|
+
{
|
38
|
+
int fd;
|
39
|
+
char filepath[ADC_LEN];
|
40
|
+
snprintf(filepath, sizeof(filepath), "%s/name", ADC_DIR);
|
41
|
+
|
42
|
+
if((fd = open(filepath, O_RDONLY | O_NONBLOCK)) < 0) // driver disabled
|
43
|
+
return 0;
|
44
|
+
|
45
|
+
close(fd);
|
46
|
+
return 1;
|
47
|
+
}
|
48
|
+
|
49
|
+
int adc_enable()
|
50
|
+
{
|
51
|
+
if(!adc_enabled()) // enable if driver is disabled
|
52
|
+
{
|
53
|
+
int fd;
|
54
|
+
if((fd = open("/sys/devices/bone_capemgr.8/slots", O_WRONLY)) < 0)
|
55
|
+
return -1;
|
56
|
+
|
57
|
+
const char * cape_bone_iio = "cape-bone-iio";
|
58
|
+
write(fd, cape_bone_iio, strlen(cape_bone_iio));
|
59
|
+
close(fd);
|
60
|
+
|
61
|
+
return 0;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
int adc_read(unsigned int ain, char * value, unsigned int length)
|
66
|
+
{
|
67
|
+
int fd, len;
|
68
|
+
char filepath[ADC_LEN];
|
69
|
+
snprintf(filepath, sizeof(filepath), "%s/in_voltage%d_raw", ADC_DIR, ain); // ie. /sys/bus/iio/devices/iio:device0/in_voltage0_raw
|
70
|
+
|
71
|
+
if((fd = open(filepath, O_RDONLY | O_NONBLOCK)) < 0)
|
72
|
+
return -1;
|
73
|
+
|
74
|
+
lseek(fd, 0, SEEK_SET);
|
75
|
+
read(fd, value, length);
|
76
|
+
close(fd);
|
77
|
+
|
78
|
+
return 0;
|
79
|
+
}
|
80
|
+
|
81
|
+
int adc_get_value(unsigned int ain, unsigned int * value)
|
82
|
+
{
|
83
|
+
const unsigned int length = 5;
|
84
|
+
char buffer[length];
|
85
|
+
|
86
|
+
if(adc_read(ain, buffer, length) < 0)
|
87
|
+
return -1;
|
88
|
+
|
89
|
+
*value = atoi(buffer);
|
90
|
+
|
91
|
+
return 0;
|
92
|
+
}
|
data/ext/bonekit/adc.h
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
adc.h
|
4
|
+
BoneKit
|
5
|
+
|
6
|
+
Copyright (cc) 2012 Luis Laugga.
|
7
|
+
Some rights reserved, all wrongs deserved.
|
8
|
+
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
10
|
+
this software and associated documentation files (the "Software"), to deal in
|
11
|
+
the Software without restriction, including without limitation the rights to
|
12
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
13
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
14
|
+
subject to the following conditions:
|
15
|
+
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
17
|
+
copies or substantial portions of the Software.
|
18
|
+
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
21
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
22
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
23
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25
|
+
|
26
|
+
*/
|
27
|
+
|
28
|
+
#ifndef BONEKIT_ADC_H__
|
29
|
+
#define BONEKIT_ADC_H__
|
30
|
+
|
31
|
+
#ifdef __cplusplus
|
32
|
+
extern "C" {
|
33
|
+
#endif
|
34
|
+
|
35
|
+
#define ADC_DIR "/sys/bus/iio/devices/iio:device0"
|
36
|
+
#define ADC_LEN 64
|
37
|
+
|
38
|
+
#define ADC_MAX_VALUE 4095 // 12 bit ADC
|
39
|
+
#define ADC_MIN_VALUE 0
|
40
|
+
|
41
|
+
#define ADC_THRESHOLD 2048 // High, value > threshold
|
42
|
+
|
43
|
+
int adc_enabled(); // 1 if adc driver is enabled
|
44
|
+
int adc_enable();
|
45
|
+
|
46
|
+
int adc_read(unsigned int, char *, unsigned int);
|
47
|
+
int adc_get_value(unsigned int, unsigned int *);
|
48
|
+
|
49
|
+
#ifdef __cplusplus
|
50
|
+
}
|
51
|
+
#endif
|
52
|
+
|
53
|
+
#endif
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
beaglebone.c
|
4
|
+
BoneKit
|
5
|
+
|
6
|
+
Copyright (cc) 2012 Luis Laugga.
|
7
|
+
Some rights reserved, all wrongs deserved.
|
8
|
+
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
10
|
+
this software and associated documentation files (the "Software"), to deal in
|
11
|
+
the Software without restriction, including without limitation the rights to
|
12
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
13
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
14
|
+
subject to the following conditions:
|
15
|
+
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
17
|
+
copies or substantial portions of the Software.
|
18
|
+
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
21
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
22
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
23
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25
|
+
|
26
|
+
*/
|
27
|
+
|
28
|
+
#include "beaglebone.h"
|
29
|
+
|
30
|
+
int beaglebone_gpio(const int b)
|
31
|
+
{
|
32
|
+
int gpio = (b & 0xff0000) >> 16;
|
33
|
+
return (gpio != 0xff ? gpio : -1);
|
34
|
+
}
|
35
|
+
|
36
|
+
int beaglebone_ain(const int b)
|
37
|
+
{
|
38
|
+
int ain = (b & 0x00ff00) >> 8;
|
39
|
+
return (ain != 0xff ? ain : -1);
|
40
|
+
}
|
41
|
+
|
42
|
+
int beaglebone_pwm_mux_mode(const int b)
|
43
|
+
{
|
44
|
+
int pwm_mux_mode = (b & 0x0000ff);
|
45
|
+
return (pwm_mux_mode != 0xff ? pwm_mux_mode : -1);
|
46
|
+
}
|
@@ -0,0 +1,141 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
beaglebone.h
|
4
|
+
BoneKit
|
5
|
+
|
6
|
+
Copyright (cc) 2012 Luis Laugga.
|
7
|
+
Some rights reserved, all wrongs deserved.
|
8
|
+
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
10
|
+
this software and associated documentation files (the "Software"), to deal in
|
11
|
+
the Software without restriction, including without limitation the rights to
|
12
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
13
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
14
|
+
subject to the following conditions:
|
15
|
+
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
17
|
+
copies or substantial portions of the Software.
|
18
|
+
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
21
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
22
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
23
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
24
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25
|
+
|
26
|
+
*/
|
27
|
+
|
28
|
+
#ifndef BONEKIT_BEAGLEBONE_H__
|
29
|
+
#define BONEKIT_BEAGLEBONE_H__
|
30
|
+
|
31
|
+
#ifdef __cplusplus
|
32
|
+
extern "C" {
|
33
|
+
#endif
|
34
|
+
|
35
|
+
// Bit mask = GPIO (0-7), AIN (8-15), PWM (16-23)
|
36
|
+
#define USR0 0x35ffff // USR0 { GPIO = 53 }
|
37
|
+
#define USR1 0x36ffff // USR1 { GPIO = 54 }
|
38
|
+
#define USR2 0x37ffff // USR2 { GPIO = 55 }
|
39
|
+
#define USR3 0x38ffff // USR3 { GPIO = 56 }
|
40
|
+
#define P8_1 0xffffff // DGND
|
41
|
+
#define P8_2 0xffffff // DGND
|
42
|
+
#define P8_3 0x26ffff // GPIO1_6 { GPIO = 38 }
|
43
|
+
#define P8_4 0x27ffff // GPIO1_7 { GPIO = 39 }
|
44
|
+
#define P8_5 0x22ffff // GPIO1_2 { GPIO = 34 }
|
45
|
+
#define P8_6 0x23ffff // GPIO1_3 { GPIO = 35 }
|
46
|
+
#define P8_7 0x42ffff // TIMER4 { GPIO = 66 }
|
47
|
+
#define P8_8 0x43ffff // TIMER7 { GPIO = 67 }
|
48
|
+
#define P8_9 0x45ffff // TIMER5 { GPIO = 69 }
|
49
|
+
#define P8_10 0x44ffff // TIMER6 { GPIO = 68 }
|
50
|
+
#define P8_11 0x2dffff // GPIO1_13 { GPIO = 45 }
|
51
|
+
#define P8_12 0x2cffff // GPIO1_12 { GPIO = 44 }
|
52
|
+
#define P8_13 0x17ff04 // EHRPWM2B { GPIO = 23, PWM_MUX_MODE = 4 }
|
53
|
+
#define P8_14 0x1affff // GPIO0_26 { GPIO = 26 }
|
54
|
+
#define P8_15 0x2fffff // GPIO1_15 { GPIO = 47 }
|
55
|
+
#define P8_16 0x2effff // GPIO1_14 { GPIO = 46 }
|
56
|
+
#define P8_17 0x1bffff // GPIO0_27 { GPIO = 27 }
|
57
|
+
#define P8_18 0x41ffff // GPIO2_1 { GPIO = 65 }
|
58
|
+
#define P8_19 0x16ff04 // EHRPWM2A { GPIO = 22, PWM_MUX_MODE = 4 }
|
59
|
+
#define P8_20 0x3fffff // GPIO1_31 { GPIO = 63 }
|
60
|
+
#define P8_21 0x3effff // GPIO1_30 { GPIO = 62 }
|
61
|
+
#define P8_22 0x25ffff // GPIO1_5 { GPIO = 37 }
|
62
|
+
#define P8_23 0x24ffff // GPIO1_4 { GPIO = 36 }
|
63
|
+
#define P8_24 0x21ffff // GPIO1_1 { GPIO = 33 }
|
64
|
+
#define P8_25 0x20ffff // GPIO1_0 { GPIO = 32 }
|
65
|
+
#define P8_26 0x3dffff // GPIO1_29 { GPIO = 61 }
|
66
|
+
#define P8_27 0x56ffff // GPIO2_22 { GPIO = 86 }
|
67
|
+
#define P8_28 0x58ffff // GPIO2_24 { GPIO = 88 }
|
68
|
+
#define P8_29 0x57ffff // GPIO2_23 { GPIO = 87 }
|
69
|
+
#define P8_30 0x59ffff // GPIO2_25 { GPIO = 89 }
|
70
|
+
#define P8_31 0x0affff // UART5_CTSN { GPIO = 10 }
|
71
|
+
#define P8_32 0x0bffff // UART5_RTSN { GPIO = 11 }
|
72
|
+
#define P8_33 0x09ffff // UART4_RTSN { GPIO = 9 }
|
73
|
+
#define P8_34 0x51ff02 // UART3_RTSN { GPIO = 81, PWM_MUX_MODE = 2 }
|
74
|
+
#define P8_35 0x08ffff // UART4_CTSN { GPIO = 8 }
|
75
|
+
#define P8_36 0x50ff02 // UART3_CTSN { GPIO = 80, PWM_MUX_MODE = 2 }
|
76
|
+
#define P8_37 0x4effff // UART5_TXD { GPIO = 78 }
|
77
|
+
#define P8_38 0x4fffff // UART5_RXD { GPIO = 79 }
|
78
|
+
#define P8_39 0x4cffff // GPIO2_12 { GPIO = 76 }
|
79
|
+
#define P8_40 0x4dffff // GPIO2_13 { GPIO = 77 }
|
80
|
+
#define P8_41 0x4affff // GPIO2_10 { GPIO = 74 }
|
81
|
+
#define P8_42 0x4bffff // GPIO2_11 { GPIO = 75 }
|
82
|
+
#define P8_43 0x48ffff // GPIO2_8 { GPIO = 72 }
|
83
|
+
#define P8_44 0x49ffff // GPIO2_9 { GPIO = 73 }
|
84
|
+
#define P8_45 0x46ff03 // GPIO2_6 { GPIO = 70, PWM_MUX_MODE = 3 }
|
85
|
+
#define P8_46 0x47ff03 // GPIO2_7 { GPIO = 71, PWM_MUX_MODE = 3 }
|
86
|
+
#define P9_1 0xffffff // DGND
|
87
|
+
#define P9_2 0xffffff // DGND
|
88
|
+
#define P9_3 0xffffff // VDD_3V3
|
89
|
+
#define P9_4 0xffffff // VDD_3V3
|
90
|
+
#define P9_5 0xffffff // VDD_5V
|
91
|
+
#define P9_6 0xffffff // VDD_5V
|
92
|
+
#define P9_7 0xffffff // SYS_5V
|
93
|
+
#define P9_8 0xffffff // SYS_5V
|
94
|
+
#define P9_9 0xffffff // PWR_BUT
|
95
|
+
#define P9_10 0xffffff // SYS_RESETn
|
96
|
+
#define P9_11 0x1effff // UART4_RXD { GPIO = 30 }
|
97
|
+
#define P9_12 0x3cffff // GPIO1_28 { GPIO = 60 }
|
98
|
+
#define P9_13 0x1fffff // UART4_TXD { GPIO = 31 }
|
99
|
+
#define P9_14 0x32ff06 // EHRPWM1A { GPIO = 50, PWM_MUX_MODE = 6 }
|
100
|
+
#define P9_15 0x30ffff // GPIO1_16 { GPIO = 48 }
|
101
|
+
#define P9_16 0x33ff06 // EHRPWM1B { GPIO = 51, PWM_MUX_MODE = 6 }
|
102
|
+
#define P9_17 0x05ffff // I2C1_SCL { GPIO = 5 }
|
103
|
+
#define P9_18 0x04ffff // I2C1_SDA { GPIO = 4 }
|
104
|
+
#define P9_19 0x0dffff // I2C2_SCL { GPIO = 13 }
|
105
|
+
#define P9_20 0x0cffff // I2C2_SDA { GPIO = 12 }
|
106
|
+
#define P9_21 0x03ff03 // UART2_TXD { GPIO = 3, PWM_MUX_MODE = 3 }
|
107
|
+
#define P9_22 0x02ff03 // UART2_RXD { GPIO = 2, PWM_MUX_MODE = 3 }
|
108
|
+
#define P9_23 0x31ffff // GPIO1_17 { GPIO = 49 }
|
109
|
+
#define P9_24 0x0fffff // UART1_TXD { GPIO = 15 }
|
110
|
+
#define P9_25 0x75ffff // GPIO3_21 { GPIO = 117 }
|
111
|
+
#define P9_26 0x0effff // UART1_RXD { GPIO = 14 }
|
112
|
+
#define P9_27 0x73ffff // GPIO3_19 { GPIO = 115 }
|
113
|
+
#define P9_28 0x71ff04 // SPI1_CS0 { GPIO = 113, PWM_MUX_MODE = 4 }
|
114
|
+
#define P9_29 0x6fff01 // SPI1_D0 { GPIO = 111, PWM_MUX_MODE = 1 }
|
115
|
+
#define P9_30 0x70ffff // SPI1_D1 { GPIO = 112 }
|
116
|
+
#define P9_31 0x6eff01 // SPI1_SCLK { GPIO = 110, PWM_MUX_MODE = 1 }
|
117
|
+
#define P9_32 0xffffff // VDD_ADC
|
118
|
+
#define P9_33 0xff04ff // AIN4 { AIN = 4 }
|
119
|
+
#define P9_34 0xffffff // GNDA_ADC
|
120
|
+
#define P9_35 0xff06ff // AIN6 { AIN = 6 }
|
121
|
+
#define P9_36 0xff05ff // AIN5 { AIN = 5 }
|
122
|
+
#define P9_37 0xff02ff // AIN2 { AIN = 2 }
|
123
|
+
#define P9_38 0xff03ff // AIN3 { AIN = 3 }
|
124
|
+
#define P9_39 0xff00ff // AIN0 { AIN = 0 }
|
125
|
+
#define P9_40 0xff01ff // AIN1 { AIN = 1 }
|
126
|
+
#define P9_41 0x14ffff // CLKOUT2 { GPIO = 20 }
|
127
|
+
#define P9_42 0x07ff00 // GPIO0_7 { GPIO = 7, PWM_MUX_MODE = 0 }
|
128
|
+
#define P9_43 0xffffff // DGND
|
129
|
+
#define P9_44 0xffffff // DGND
|
130
|
+
#define P9_45 0xffffff // DGND
|
131
|
+
#define P9_46 0xffffff // DGND
|
132
|
+
|
133
|
+
int beaglebone_gpio(const int);
|
134
|
+
int beaglebone_ain(const int);
|
135
|
+
int beaglebone_pwm_mux_mode(const int);
|
136
|
+
|
137
|
+
#ifdef __cplusplus
|
138
|
+
}
|
139
|
+
#endif
|
140
|
+
|
141
|
+
#endif
|