beaglebone 1.0.6 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b19c474402f31c4baf1e2965ba0f49327cb40ba8
4
- data.tar.gz: 2b05ac032cefc71bfc53561c82b1bdf62ed02ce6
3
+ metadata.gz: e1e67c458b2531e22e6448a1a7f48cefbc6fb938
4
+ data.tar.gz: 4b01929c1291294281617ad65f49ace68a8e3497
5
5
  SHA512:
6
- metadata.gz: 8f5ab52cdace0e05a025c9b43fdaeb9133e52ef0ca941f374dbed18fc695a7c97c0d65e48d548125e88a561b8e5be361c6d8fa7cbc75ffd2f852b9d233220cfc
7
- data.tar.gz: 67586adfc78e6d4ba5c719a8d53e657bed0608933c643349c407b522ae908fd51467d18eff86aef564e910e4d2f0ca00da442e2e5ed161d7fd769aad66f75c2d
6
+ metadata.gz: 4c200e3754b49ab4e4870453faa28c7c6bc7b6b16895ce6df9dcd8c16e16bfdbf42aadfc7c6ac3c03b8ac2b6025686b6f611e123a1d47e30ab17994473169382
7
+ data.tar.gz: d17903bf3d475051bb24ceb0efaaff537c2a55e1852155903e397186eb073d1f9e04fb033636b6eb62ed209359231054970c1c64e2bc5c1ab1fe8ee305199d94
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
1
  # Beaglebone Ruby Library
2
- Documentation is in progress and will be completed shortly.
3
2
 
4
3
  **Table of Contents**
5
4
  - [Overview](#overview)
@@ -7,7 +6,14 @@ Documentation is in progress and will be completed shortly.
7
6
  - [Installing Ruby](#installing-ruby)
8
7
  - [Installing Beaglebone Gem](#installing-beaglebone-gem)
9
8
  - [Usage](#usage)
10
- - [Reference](#reference)
9
+ - [Pin Information](#pin-information)
10
+ - [GPIO Pins](#gpio-pins)
11
+ - [Analog Pins](#analog-pins)
12
+ - [PWM Pins](#pwm-pins)
13
+ - [UART Pins](#uart-pins)
14
+ - [I2C Pins](#i2c-pins)
15
+ - [SPI Pins](#spi-pins)
16
+ - [Source Code Reference](#source-code-reference)
11
17
  - [Examples (Object Oriented)](#examples-object-oriented)
12
18
  - [GPIO](#gpio)
13
19
  - [GPIO Writing](#gpio-writing)
@@ -36,7 +42,6 @@ Documentation is in progress and will be completed shortly.
36
42
  - [SPI Data Transfer](#spi-data-transfer)
37
43
  - [MCP3008 Example](#mcp3008-example)
38
44
  - [Examples (Procedural)](#examples-procedural)
39
- - [Pin Reference](#pin-reference)
40
45
  - [License](#license)
41
46
 
42
47
  ## Overview
@@ -66,8 +71,44 @@ require 'beaglebone'
66
71
  include Beaglebone
67
72
  ```
68
73
 
69
- ## Rereference
70
- A full reference is available [here](http://rubydoc.info/gems/beaglebone/1.0.5/frames).
74
+ ## Pin Information
75
+ The Beaglebone has two headers of IO pins. Documentation on these pins is available [here](http://beagleboard.org/Support/bone101#headers).
76
+
77
+ ### GPIO Pins
78
+ The beaglebone has a large number of GPIO pins. These pins function at 3.3v. Do not provide more than 3.3v to any GPIO pin or risk damaging the hardware.
79
+
80
+ Not all GPIO pins will be usable. Currently there is a bug affecting P9_17 and P9_18. They do not function in the latest Debian image.
81
+
82
+ There are built in _capes_ that have priority over the GPIO pins unless disabled. These are for HDMI and the onboard eMMC. It is documented [here](http://beagleboard.org/Support/bone101#headers-black). It is possible to disable these _capes_ if you are not using them.
83
+
84
+ ### Analog Pins
85
+ The beaglebone has 7 Analog inputs. Documentation on these pins is available [here](http://beagleboard.org/Support/bone101#headers-analog). These pins function at 1.8v. Do not provide more than 1.8v to any Analog pin or risk damaging the hardware. The header has pins available to provide a 1.8v for analog devices as well as a dedicated analog ground.
86
+
87
+ ### PWM Pins
88
+ The beaglebone has 8 PWM pins. Documentation on these pins is available [here](http://beagleboard.org/Support/bone101#headers-pwm). These pins function at 3.3v.
89
+
90
+ Not all 8 pins may be used at the same time. You may use the following pins.
91
+
92
+ - P8_13 or P8_19
93
+ - P9_14 or P9_16
94
+ - P9_21 or P9_22
95
+ - P9_28 and P9_42
96
+
97
+ ### UART Pins
98
+ The beaglebone has 5 UART devices available. Documentation on these pins is available [here](http://beagleboard.org/Support/bone101#headers-serial). These pins function at 3.3v. Do not provide more than 3.3v to any UART pin or risk damaging the hardware.
99
+
100
+ UART3 only has a TX pin available.
101
+
102
+ UART5 TX and RX pins are unavailable by default, as the HDMI _cape_ claims those pins unless disabled.
103
+
104
+ ### I2C Pins
105
+ The beaglebone has 2 I2C devices available. Documentation on these pins is available [here](http://beagleboard.org/Support/bone101#headers-i2c). These pins function at 3.3v. Do not provide more than 3.3v to any I2C pin or risk damaging the hardware.
106
+
107
+ ### SPI Pins
108
+ The beaglebone has 2 SPI devices available. Documentation on these pins is available [here](http://beagleboard.org/Support/bone101#headers-spi). These pins function at 3.3v. Do not provide more than 3.3v to any SPI pin or risk damaging the hardware.
109
+
110
+ ## Source Code Reference
111
+ A full Source Code reference is available [here](http://rubydoc.info/gems/beaglebone/1.0.5/frames).
71
112
 
72
113
  ## Examples (Object Oriented)
73
114
  These examples will show the various ways to interact with the Beaglebones IO hardware. They will need to be executed as root in order to function correctly.
@@ -148,7 +189,7 @@ end
148
189
  ```
149
190
 
150
191
  #### Edge Triggers
151
- The Beaglebone can also monitor for changes on a GPIO pin. This is called an edge trigger. Since this is interrupt based on the Beaglebone, waiting for a change does not waste CPU cycles by constantly polling the pin.
192
+ The Beaglebone can monitor for changes on a GPIO pin. This is called an edge trigger. Since this is interrupt based on the Beaglebone, waiting for a change does not waste CPU cycles by constantly polling the pin.
152
193
 
153
194
  The following trigger types are supported
154
195
  - Rising: Triggered when the state goes from low to high
@@ -208,7 +249,7 @@ p9_11.set_gpio_edge(:RISING)
208
249
  ```
209
250
 
210
251
  #### Shift Registers
211
- This library will also support writing to shift registers using GPIO pins. Create a **ShiftRegister** object by initializing it with the latch pin, clock pin, and data pin.
252
+ This library will support writing to shift registers using GPIO pins. Create a **ShiftRegister** object by initializing it with the latch pin, clock pin, and data pin.
212
253
 
213
254
  This example will trigger 8 pins of a shift register.
214
255
 
@@ -391,6 +432,12 @@ p9_14.set_duty_cycle_ns(31250000)
391
432
  # Invert the output signal
392
433
  p9_14.set_polarity(:INVERTED)
393
434
 
435
+ # Stop the output signal
436
+ p9_14.stop
437
+
438
+ # Resume the output signal
439
+ p9_14.run
440
+
394
441
  # Disable the output signal
395
442
  p9_14.disable_pwm_pin
396
443
  ```
@@ -527,6 +574,10 @@ To read from an I2C device, the method **#read** is used.
527
574
  This example communicates with an [LSM303DLHC](https://www.adafruit.com/products/1120) Accelerometer/Compass/Thermometer device.
528
575
 
529
576
  ```ruby
577
+ #!/usr/bin/env ruby
578
+ require 'beaglebone'
579
+ include Beaglebone
580
+
530
581
  # Initialize I2C device I2C2
531
582
  i2c = I2CDevice.new(:I2C2)
532
583
 
@@ -579,7 +630,7 @@ The beaglebone has a number of SPI devices. These operate at 3.3v. Do not prov
579
630
 
580
631
  To initialize the SPI device **SPI0**, pass the symbol for that device to the **SPIDevice** constructor.
581
632
 
582
- The optional arguments are also available
633
+ The optional arguments are available
583
634
  - mode: SPI mode, :SPI_MODE_0 through :SPI_MODE_3
584
635
  - speed: Speed of the SPI device
585
636
  - bpw: Bits per word
@@ -603,7 +654,7 @@ spi.set_bpw(10)
603
654
  spi.disable
604
655
  ```
605
656
 
606
- #### SPI Data Tramsfer
657
+ #### SPI Data Transfer
607
658
  To transfer data to an SPI device, the method **#xfer** is used.
608
659
 
609
660
  **#xfer** takes the following arguments
@@ -613,12 +664,16 @@ To transfer data to an SPI device, the method **#xfer** is used.
613
664
  - delay: (optional) delay
614
665
  - bpw: (optonal) bits per word
615
666
 
616
- **#xfer** returns the bytes read from the SPI device.
667
+ **#xfer** returns the data read from the SPI device.
617
668
 
618
669
  #### MCP3008 Example
619
670
  This example communicates with an [MCP3008](http://www.adafruit.com/products/856) ADC device.
620
671
 
621
672
  ```ruby
673
+ #!/usr/bin/env ruby
674
+ require 'beaglebone'
675
+ include Beaglebone
676
+
622
677
  # Initialize SPI device SPI0
623
678
  spi = SPIDevice.new(:SPI0)
624
679
 
@@ -629,7 +684,7 @@ spi = SPIDevice.new(:SPI0)
629
684
  # Read value from channel 0
630
685
  raw = spi.xfer([ 0b00000001, 0b10000000, 0].pack("C*"))
631
686
 
632
- # split data read into an array of characters
687
+ # Split data read into an array of characters
633
688
  data = raw.unpack("C*")
634
689
 
635
690
  # The returned data is stored starting at the last two bits of the second byte
@@ -641,7 +696,7 @@ puts "Value of channel 0: #{val}"
641
696
  # Read value from channel 1
642
697
  raw = spi.xfer([ 0b00000001, 0b10010000, 0].pack("C*"))
643
698
 
644
- # split data read into an array of characters
699
+ # Split data read into an array of characters
645
700
  data = raw.unpack("C*")
646
701
 
647
702
  # The returned data is stored starting at the last two bits of the second byte
@@ -649,12 +704,40 @@ val = ((data[1] & 0b00000011) << 8 ) | data[2]
649
704
 
650
705
  # Display the value of channel 1
651
706
  puts "Value of channel 1: #{val}"
707
+
708
+ # Disable SPI device
709
+ spi.disable
652
710
  ```
653
711
 
654
712
  ## Examples (Procedural)
713
+ This library supports _procedural_ methods as well as _objet oriented_ methods. They are virtually identical to the _object oriented_ methods, except the first argument they take is the pin. If a callback is required, it is still passed first, before the pin. The examples directory has sample code in both formats.
714
+
715
+ The procedural versions of the examples are available in the file [procedural-examples.md](procedural-examples.md).
655
716
 
717
+ Instead of constructors, the following methods are used to initialize the pins and devices on the Beaglebone.
656
718
 
657
- ## Pin Reference
719
+ ```ruby
720
+ # GPIOPin.new becomes
721
+ GPIO.pin_mode(:P9_12, :OUT)
722
+
723
+ # To set the state of the pin
724
+ GPIO.digital_write(:P9_12, :OUT)
725
+
726
+ # Analog pins do not require setup, and can be read at any time
727
+ AIN.read(:P9_33)
728
+
729
+ # PWMPin.new becomes
730
+ PWM.start(:P9_14, 90, 10, :NORMAL)
731
+
732
+ # UARTDevice.new becomes
733
+ UART.setup(:UART1, 9600)
734
+
735
+ # I2CDevice.new becomes
736
+ I2C.setup(:I2C2)
737
+
738
+ # SPIDevice.new becomes
739
+ SPI.setup(:SPI0)
740
+ ```
658
741
 
659
742
  ## License
660
- Copyright (c) 2014 Rob Mosher. Distributed under the GPL-v3 License. See LICENSE for more information.
743
+ Copyright (c) 2014 Rob Mosher. Distributed under the GPL-v3 License. See [LICENSE](LICENSE) for more information.
data/beaglebone.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'beaglebone'
3
- s.version = '1.0.6'
3
+ s.version = '1.1.0'
4
4
  s.date = '2014-04-13'
5
5
  s.summary = 'Beaglebone IO Gem'
6
6
  s.description = 'A Full Featured Beaglebone IO Gem'