class BeagleBoard::FreeBSD::Gpio
Constants
- GPIO_PIN_HIGH
- GPIO_PIN_INPUT
- GPIO_PIN_INVIN
- GPIO_PIN_INVOUT
- GPIO_PIN_LOW
- GPIO_PIN_OPENDRAIN
- GPIO_PIN_OUTPUT
- GPIO_PIN_PULLDOWN
- GPIO_PIN_PULLUP
- GPIO_PIN_PUSHPULL
- GPIO_PIN_TRISTATE
- GPIO_VALUE_HIGH
- GPIO_VALUE_INVALID
- GPIO_VALUE_LOW
Public Class Methods
new(bank, gpio)
click to toggle source
Calls superclass method
BeagleBoard::Base::Gpio::new
# File lib/beagleboard/freebsd/gpio.rb, line 50 def initialize(bank, gpio) super end
Public Instance Methods
close()
click to toggle source
# File lib/beagleboard/freebsd/gpio.rb, line 58 def close gpio_close(@bank_fd) end
direction()
click to toggle source
# File lib/beagleboard/freebsd/gpio.rb, line 66 def direction case gpio_pin_config(@bank_fd, @gpio) when GPIO_PIN_INPUT then :in when GPIO_PIN_OUTPUT then :out end end
direction=(direction)
click to toggle source
# File lib/beagleboard/freebsd/gpio.rb, line 73 def direction=(direction) send(direction_function(direction), @bank_fd, @gpio) self.value = direction_value(direction) end
open()
click to toggle source
# File lib/beagleboard/freebsd/gpio.rb, line 54 def open @bank_fd = gpio_open(@bank) end
toggle()
click to toggle source
# File lib/beagleboard/freebsd/gpio.rb, line 62 def toggle gpio_pin_toggle(@bank_fd, @gpio) end
value()
click to toggle source
# File lib/beagleboard/freebsd/gpio.rb, line 78 def value res = Gpio.gpio_pin_get(@bank_fd, @gpio) raise 'Read error' if res < 0 res end
value=(value)
click to toggle source
# File lib/beagleboard/freebsd/gpio.rb, line 86 def value=(value) return unless value res = send(value_function(value), @bank_fd, @gpio) raise StandardError, 'Write error' if res < 0 end
Private Instance Methods
direction_function(direction)
click to toggle source
# File lib/beagleboard/freebsd/gpio.rb, line 94 def direction_function(direction) { in: :gpio_pin_input, out: :gpio_pin_output, low: :gpio_pin_output, high: :gpio_pin_output }[direction] end
direction_value(direction)
click to toggle source
# File lib/beagleboard/freebsd/gpio.rb, line 103 def direction_value(direction) { in: nil, out: nil, low: 0, high: 1 }[direction] end
value_function(value)
click to toggle source
# File lib/beagleboard/freebsd/gpio.rb, line 112 def value_function(value) { 0 => :gpio_pin_low, 1 => :gpio_pin_high, nil => nil }[value] end