2013-07-30 16:06:02 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
Package rpio provides GPIO access on the Raspberry PI without any need
|
|
|
|
for external c libraries (ex: WiringPI or BCM2835).
|
|
|
|
|
|
|
|
Supports simple operations such as:
|
2017-11-14 17:52:05 +01:00
|
|
|
- Pin mode/direction (input/output/clock)
|
2013-07-30 16:06:02 +02:00
|
|
|
- Pin write (high/low)
|
|
|
|
- Pin read (high/low)
|
2013-07-30 19:25:43 +02:00
|
|
|
- Pull up/down/off
|
2013-07-30 16:06:02 +02:00
|
|
|
|
|
|
|
Example of use:
|
|
|
|
|
|
|
|
rpio.Open()
|
|
|
|
defer rpio.Close()
|
|
|
|
|
|
|
|
pin := rpio.Pin(4)
|
|
|
|
pin.Output()
|
|
|
|
|
|
|
|
for {
|
|
|
|
pin.Toggle()
|
|
|
|
time.Sleep(time.Second)
|
|
|
|
}
|
|
|
|
|
|
|
|
The library use the raw BCM2835 pinouts, not the ports as they are mapped
|
|
|
|
on the output pins for the raspberry pi
|
|
|
|
|
|
|
|
Rev 1 Raspberry Pi
|
|
|
|
+------+------+--------+
|
|
|
|
| GPIO | Phys | Name |
|
|
|
|
+------+------+--------+
|
|
|
|
| 0 | 3 | SDA |
|
|
|
|
| 1 | 5 | SCL |
|
|
|
|
| 4 | 7 | GPIO 7 |
|
|
|
|
| 7 | 26 | CE1 |
|
|
|
|
| 8 | 24 | CE0 |
|
|
|
|
| 9 | 21 | MISO |
|
|
|
|
| 10 | 19 | MOSI |
|
|
|
|
| 11 | 23 | SCLK |
|
|
|
|
| 14 | 8 | TxD |
|
|
|
|
| 15 | 10 | RxD |
|
|
|
|
| 17 | 11 | GPIO 0 |
|
|
|
|
| 18 | 12 | GPIO 1 |
|
|
|
|
| 21 | 13 | GPIO 2 |
|
|
|
|
| 22 | 15 | GPIO 3 |
|
|
|
|
| 23 | 16 | GPIO 4 |
|
|
|
|
| 24 | 18 | GPIO 5 |
|
|
|
|
| 25 | 22 | GPIO 6 |
|
|
|
|
+------+------+--------+
|
|
|
|
|
|
|
|
See the spec for full details of the BCM2835 controller:
|
|
|
|
http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2013-07-30 16:12:13 +02:00
|
|
|
package rpio
|
2013-07-30 16:06:02 +02:00
|
|
|
|
|
|
|
import (
|
2015-03-08 02:57:06 +01:00
|
|
|
"bytes"
|
2015-03-08 03:45:00 +01:00
|
|
|
"encoding/binary"
|
2013-07-30 16:06:02 +02:00
|
|
|
"os"
|
|
|
|
"reflect"
|
|
|
|
"sync"
|
|
|
|
"syscall"
|
2013-07-30 19:25:43 +02:00
|
|
|
"time"
|
2013-07-30 16:06:02 +02:00
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2017-11-14 17:52:05 +01:00
|
|
|
type Mode uint8
|
2013-07-30 16:06:02 +02:00
|
|
|
type Pin uint8
|
|
|
|
type State uint8
|
2013-07-30 19:25:43 +02:00
|
|
|
type Pull uint8
|
2013-07-30 16:06:02 +02:00
|
|
|
|
|
|
|
// Memory offsets for gpio, see the spec for more details
|
|
|
|
const (
|
|
|
|
bcm2835Base = 0x20000000
|
2017-11-14 22:33:04 +01:00
|
|
|
gpioOffset = 0x200000
|
|
|
|
clkOffset = 0x101000
|
2017-11-14 22:04:03 +01:00
|
|
|
|
|
|
|
memLength = 4096
|
2013-07-30 16:06:02 +02:00
|
|
|
)
|
|
|
|
|
2017-11-14 22:04:03 +01:00
|
|
|
var (
|
|
|
|
gpioBase int64
|
2017-11-14 22:33:04 +01:00
|
|
|
clkBase int64
|
2017-11-14 22:04:03 +01:00
|
|
|
)
|
|
|
|
|
2017-11-14 22:33:04 +01:00
|
|
|
func init() {
|
2017-11-15 17:48:18 +01:00
|
|
|
base := getBase()
|
2017-11-14 22:04:03 +01:00
|
|
|
gpioBase = base + gpioOffset
|
|
|
|
clkBase = base + clkOffset
|
|
|
|
}
|
|
|
|
|
2017-11-14 17:52:05 +01:00
|
|
|
// Pin mode, a pin can be set in Input or Output mode, or clock
|
2013-07-30 16:06:02 +02:00
|
|
|
const (
|
2017-11-14 17:52:05 +01:00
|
|
|
Input Mode = iota
|
2013-07-30 16:06:02 +02:00
|
|
|
Output
|
2017-11-14 17:52:05 +01:00
|
|
|
Clock
|
2013-07-30 16:06:02 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// State of pin, High / Low
|
|
|
|
const (
|
|
|
|
Low State = iota
|
|
|
|
High
|
|
|
|
)
|
|
|
|
|
2013-07-30 19:25:43 +02:00
|
|
|
// Pull Up / Down / Off
|
|
|
|
const (
|
|
|
|
PullOff Pull = iota
|
|
|
|
PullDown
|
|
|
|
PullUp
|
|
|
|
)
|
|
|
|
|
2013-07-30 16:06:02 +02:00
|
|
|
// Arrays for 8 / 32 bit access to memory and a semaphore for write locking
|
|
|
|
var (
|
2017-11-14 22:33:04 +01:00
|
|
|
memlock sync.Mutex
|
|
|
|
gpioMem []uint32
|
|
|
|
clkMem []uint32
|
|
|
|
gpioMem8 []uint8
|
|
|
|
clkMem8 []uint8
|
2013-07-30 16:06:02 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Set pin as Input
|
|
|
|
func (pin Pin) Input() {
|
|
|
|
PinMode(pin, Input)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set pin as Output
|
|
|
|
func (pin Pin) Output() {
|
|
|
|
PinMode(pin, Output)
|
|
|
|
}
|
|
|
|
|
2017-11-14 23:16:39 +01:00
|
|
|
// Set pin as Clock
|
|
|
|
func (pin Pin) Clock() {
|
2017-11-14 17:52:05 +01:00
|
|
|
PinMode(pin, Clock)
|
|
|
|
}
|
|
|
|
|
2013-07-30 16:06:02 +02:00
|
|
|
// Set pin High
|
|
|
|
func (pin Pin) High() {
|
|
|
|
WritePin(pin, High)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set pin Low
|
|
|
|
func (pin Pin) Low() {
|
|
|
|
WritePin(pin, Low)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Toggle pin state
|
|
|
|
func (pin Pin) Toggle() {
|
|
|
|
TogglePin(pin)
|
|
|
|
}
|
|
|
|
|
2017-11-14 23:16:39 +01:00
|
|
|
func (pin Pin) Freq(freq int) {
|
|
|
|
SetFreq(pin, freq)
|
|
|
|
}
|
|
|
|
|
2017-11-14 17:52:05 +01:00
|
|
|
// Set pin Mode
|
|
|
|
func (pin Pin) Mode(mode Mode) {
|
|
|
|
PinMode(pin, mode)
|
2013-07-30 16:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set pin state (high/low)
|
|
|
|
func (pin Pin) Write(state State) {
|
|
|
|
WritePin(pin, state)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read pin state (high/low)
|
|
|
|
func (pin Pin) Read() State {
|
|
|
|
return ReadPin(pin)
|
|
|
|
}
|
|
|
|
|
2013-07-30 19:25:43 +02:00
|
|
|
// Set a given pull up/down mode
|
|
|
|
func (pin Pin) Pull(pull Pull) {
|
|
|
|
PullMode(pin, pull)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pull up pin
|
|
|
|
func (pin Pin) PullUp() {
|
|
|
|
PullMode(pin, PullUp)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pull down pin
|
|
|
|
func (pin Pin) PullDown() {
|
|
|
|
PullMode(pin, PullDown)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disable pullup/down on pin
|
|
|
|
func (pin Pin) PullOff() {
|
|
|
|
PullMode(pin, PullOff)
|
|
|
|
}
|
|
|
|
|
2017-11-14 17:52:05 +01:00
|
|
|
// PinMode sets the mode (direction) of a given pin (Input, Output or Clock)
|
2017-11-15 11:26:49 +01:00
|
|
|
//
|
|
|
|
// Clock is possible only for some pins (bcm 4, 5, 6, 20, 21)
|
2017-11-14 17:52:05 +01:00
|
|
|
func PinMode(pin Pin, mode Mode) {
|
2013-07-30 16:06:02 +02:00
|
|
|
|
|
|
|
// Pin fsel register, 0 or 1 depending on bank
|
2017-11-14 22:16:15 +01:00
|
|
|
fselReg := uint8(pin) / 10
|
2013-07-30 16:06:02 +02:00
|
|
|
shift := (uint8(pin) % 10) * 3
|
2017-11-14 17:52:05 +01:00
|
|
|
f := uint32(0)
|
2013-07-30 16:06:02 +02:00
|
|
|
|
2017-11-14 17:52:05 +01:00
|
|
|
switch mode {
|
|
|
|
case Input:
|
|
|
|
f = 0 // 000
|
|
|
|
case Output:
|
|
|
|
f = 1 // 001
|
|
|
|
case Clock:
|
|
|
|
switch pin {
|
|
|
|
case 4, 5, 6, 32, 34, 42, 43, 44:
|
|
|
|
f = 4 // 100 - alt0
|
|
|
|
case 20, 21:
|
|
|
|
f = 2 // 010 - alt5
|
|
|
|
default:
|
2017-11-14 22:04:03 +01:00
|
|
|
return
|
2017-11-14 17:52:05 +01:00
|
|
|
}
|
2013-07-30 16:06:02 +02:00
|
|
|
}
|
2017-11-14 22:25:26 +01:00
|
|
|
|
|
|
|
memlock.Lock()
|
|
|
|
defer memlock.Unlock()
|
|
|
|
|
|
|
|
const pinMask = 7 // 0b111 - pinmode is 3 bits
|
|
|
|
|
2017-11-14 22:16:15 +01:00
|
|
|
gpioMem[fselReg] = (gpioMem[fselReg] &^ (pinMask << shift)) | (f << shift)
|
2013-07-30 16:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// WritePin sets a given pin High or Low
|
|
|
|
// by setting the clear or set registers respectively
|
|
|
|
func WritePin(pin Pin, state State) {
|
|
|
|
|
|
|
|
p := uint8(pin)
|
|
|
|
|
|
|
|
// Clear register, 10 / 11 depending on bank
|
|
|
|
// Set register, 7 / 8 depending on bank
|
|
|
|
clearReg := p/32 + 10
|
|
|
|
setReg := p/32 + 7
|
|
|
|
|
|
|
|
memlock.Lock()
|
2014-08-23 14:39:31 +02:00
|
|
|
defer memlock.Unlock()
|
2013-07-30 16:06:02 +02:00
|
|
|
|
|
|
|
if state == Low {
|
2017-11-14 22:04:03 +01:00
|
|
|
gpioMem[clearReg] = 1 << (p & 31)
|
2013-07-30 16:06:02 +02:00
|
|
|
} else {
|
2017-11-14 22:04:03 +01:00
|
|
|
gpioMem[setReg] = 1 << (p & 31)
|
2013-07-30 16:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-01-07 23:15:25 +01:00
|
|
|
// Read the state of a pin
|
2013-07-30 16:06:02 +02:00
|
|
|
func ReadPin(pin Pin) State {
|
|
|
|
// Input level register offset (13 / 14 depending on bank)
|
|
|
|
levelReg := uint8(pin)/32 + 13
|
|
|
|
|
2017-11-14 22:33:04 +01:00
|
|
|
if (gpioMem[levelReg] & (1 << uint8(pin&31))) != 0 {
|
2013-07-30 16:06:02 +02:00
|
|
|
return High
|
|
|
|
}
|
|
|
|
|
|
|
|
return Low
|
|
|
|
}
|
|
|
|
|
|
|
|
// Toggle a pin state (high -> low -> high)
|
|
|
|
// TODO: probably possible to do this much faster without read
|
|
|
|
func TogglePin(pin Pin) {
|
|
|
|
switch ReadPin(pin) {
|
|
|
|
case Low:
|
|
|
|
pin.High()
|
|
|
|
case High:
|
|
|
|
pin.Low()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-30 19:25:43 +02:00
|
|
|
func PullMode(pin Pin, pull Pull) {
|
|
|
|
// Pull up/down/off register has offset 38 / 39, pull is 37
|
|
|
|
pullClkReg := uint8(pin)/32 + 38
|
|
|
|
pullReg := 37
|
|
|
|
shift := (uint8(pin) % 32)
|
|
|
|
|
|
|
|
memlock.Lock()
|
2014-08-23 14:39:31 +02:00
|
|
|
defer memlock.Unlock()
|
2013-07-30 19:25:43 +02:00
|
|
|
|
|
|
|
switch pull {
|
|
|
|
case PullDown, PullUp:
|
2017-11-14 22:04:03 +01:00
|
|
|
gpioMem[pullReg] = gpioMem[pullReg]&^3 | uint32(pull)
|
2013-07-30 19:25:43 +02:00
|
|
|
case PullOff:
|
2017-11-14 22:04:03 +01:00
|
|
|
gpioMem[pullReg] = gpioMem[pullReg] &^ 3
|
2013-07-30 19:25:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Wait for value to clock in, this is ugly, sorry :(
|
|
|
|
time.Sleep(time.Microsecond)
|
|
|
|
|
2017-11-14 22:04:03 +01:00
|
|
|
gpioMem[pullClkReg] = 1 << shift
|
2013-07-30 19:25:43 +02:00
|
|
|
|
|
|
|
// Wait for value to clock in
|
|
|
|
time.Sleep(time.Microsecond)
|
|
|
|
|
2017-11-14 22:04:03 +01:00
|
|
|
gpioMem[pullReg] = gpioMem[pullReg] &^ 3
|
|
|
|
gpioMem[pullClkReg] = 0
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set clock speed for given pin
|
|
|
|
//
|
2017-11-14 22:16:15 +01:00
|
|
|
// freq should be in range 4688Hz - 19.2MHz to prevent unexpected behavior
|
2017-11-14 22:04:03 +01:00
|
|
|
// (for smaller frequencies implement custom software clock using output pin and sleep)
|
|
|
|
//
|
2017-11-14 22:16:15 +01:00
|
|
|
// Note that some pins share the same clock source, it means that
|
|
|
|
// changing frequency for one pin will change it also for all pins within a group
|
2017-11-14 22:04:03 +01:00
|
|
|
// The groups are: clk0 (4, 20, 32, 34), clk1 (5, 21, 42, 43) and clk2 (6 and 43)
|
2017-11-14 23:16:39 +01:00
|
|
|
func SetFreq(pin Pin, freq int) {
|
2017-11-14 22:04:03 +01:00
|
|
|
const source = 19200000 // oscilator frequency
|
|
|
|
const maxUint12 = 4095
|
|
|
|
|
|
|
|
divi := uint32(source / freq)
|
2017-11-15 11:26:49 +01:00
|
|
|
divf := uint32(((source % freq) << 12) / freq)
|
2017-11-14 22:04:03 +01:00
|
|
|
|
|
|
|
divi &= maxUint12
|
|
|
|
divf &= maxUint12
|
|
|
|
|
2017-11-14 22:16:15 +01:00
|
|
|
clkCtlReg := 0x70
|
|
|
|
clkDivReg := 0x74
|
2017-11-14 22:04:03 +01:00
|
|
|
switch pin {
|
2017-11-14 22:33:04 +01:00
|
|
|
case 4, 20, 32, 34: // clk0
|
|
|
|
clkCtlReg += 0
|
|
|
|
clkDivReg += 0
|
|
|
|
case 5, 21, 42, 44: // clk1
|
|
|
|
clkCtlReg += 8
|
|
|
|
clkDivReg += 8
|
|
|
|
case 6, 43: // clk2
|
|
|
|
clkCtlReg += 16
|
|
|
|
clkDivReg += 16
|
|
|
|
default:
|
|
|
|
return
|
2017-11-14 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
memlock.Lock()
|
|
|
|
defer memlock.Unlock()
|
|
|
|
|
|
|
|
const PASSWORD = 0x5A000000
|
|
|
|
const busy = 0x80
|
|
|
|
const enab = 0x10
|
|
|
|
const src = 0x01 // oscilator
|
|
|
|
|
2017-11-14 22:16:15 +01:00
|
|
|
clkMem[clkCtlReg] = PASSWORD | src // stop gpio clock
|
2017-11-14 22:33:04 +01:00
|
|
|
for clkMem[clkCtlReg]&busy != 0 {
|
|
|
|
} // ... and wait
|
2017-11-14 22:04:03 +01:00
|
|
|
|
2017-11-14 22:16:15 +01:00
|
|
|
clkMem[clkDivReg] = PASSWORD | (divi << 12) | divf // set dividers
|
2017-11-14 22:33:04 +01:00
|
|
|
clkMem[clkCtlReg] = PASSWORD | enab | src // start clock
|
2013-07-30 19:25:43 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-07-30 16:06:02 +02:00
|
|
|
// Open and memory map GPIO memory range from /dev/mem .
|
|
|
|
// Some reflection magic is used to convert it to a unsafe []uint32 pointer
|
|
|
|
func Open() (err error) {
|
|
|
|
var file *os.File
|
|
|
|
|
2017-11-14 23:16:39 +01:00
|
|
|
// Open fd for rw mem access; try gpiomem first
|
2017-11-14 17:06:00 +01:00
|
|
|
file, err = os.OpenFile("/dev/gpiomem", os.O_RDWR|os.O_SYNC, 0)
|
2017-11-14 22:04:03 +01:00
|
|
|
if os.IsNotExist(err) { // try mem (need root)
|
|
|
|
file, err = os.OpenFile("/dev/mem", os.O_RDWR|os.O_SYNC, 0)
|
2015-12-07 13:31:10 +01:00
|
|
|
}
|
2013-07-30 16:06:02 +02:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// FD can be closed after memory mapping
|
|
|
|
defer file.Close()
|
|
|
|
|
|
|
|
memlock.Lock()
|
2014-08-23 14:39:31 +02:00
|
|
|
defer memlock.Unlock()
|
2013-07-30 16:06:02 +02:00
|
|
|
|
2017-11-14 22:04:03 +01:00
|
|
|
// Memory map GPIO registers to slice
|
2017-11-14 22:16:15 +01:00
|
|
|
gpioMem, gpioMem8, err = memMap(file.Fd(), gpioBase)
|
2017-11-14 22:04:03 +01:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Memory map clock reisters to slice
|
2017-11-14 22:16:15 +01:00
|
|
|
clkMem, clkMem8, err = memMap(file.Fd(), clkBase)
|
2017-11-14 22:04:03 +01:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-11-15 17:48:18 +01:00
|
|
|
func memMap(fd uintptr, base int64) (mem []uint32, mem8 []byte, err error) {
|
2013-07-30 16:06:02 +02:00
|
|
|
mem8, err = syscall.Mmap(
|
2017-11-14 22:04:03 +01:00
|
|
|
int(fd),
|
2017-11-15 17:48:18 +01:00
|
|
|
base,
|
2013-07-30 16:06:02 +02:00
|
|
|
memLength,
|
|
|
|
syscall.PROT_READ|syscall.PROT_WRITE,
|
2017-11-14 17:06:00 +01:00
|
|
|
syscall.MAP_SHARED,
|
|
|
|
)
|
2013-07-30 16:06:02 +02:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// Convert mapped byte memory to unsafe []uint32 pointer, adjust length as needed
|
|
|
|
header := *(*reflect.SliceHeader)(unsafe.Pointer(&mem8))
|
|
|
|
header.Len /= (32 / 8) // (32 bit = 4 bytes)
|
|
|
|
header.Cap /= (32 / 8)
|
|
|
|
mem = *(*[]uint32)(unsafe.Pointer(&header))
|
2017-11-14 22:04:03 +01:00
|
|
|
return
|
2013-07-30 16:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Close unmaps GPIO memory
|
2014-08-23 14:39:31 +02:00
|
|
|
func Close() error {
|
2013-07-30 16:06:02 +02:00
|
|
|
memlock.Lock()
|
2014-08-23 14:39:31 +02:00
|
|
|
defer memlock.Unlock()
|
2017-11-14 22:33:04 +01:00
|
|
|
if err := syscall.Munmap(gpioMem8); err != nil {
|
2017-11-14 22:25:26 +01:00
|
|
|
return err
|
|
|
|
}
|
2017-11-14 22:33:04 +01:00
|
|
|
if err := syscall.Munmap(clkMem8); err != nil {
|
2017-11-14 22:25:26 +01:00
|
|
|
return err
|
|
|
|
}
|
2017-11-14 22:04:03 +01:00
|
|
|
return nil
|
2013-07-30 16:06:02 +02:00
|
|
|
}
|
2015-03-08 02:57:06 +01:00
|
|
|
|
2015-03-08 03:54:44 +01:00
|
|
|
// Read /proc/device-tree/soc/ranges and determine the base address.
|
|
|
|
// Use the default Raspberry Pi 1 base address if this fails.
|
2017-11-14 22:04:03 +01:00
|
|
|
func getBase() (base int64) {
|
|
|
|
base = bcm2835Base
|
2015-03-08 03:45:00 +01:00
|
|
|
ranges, err := os.Open("/proc/device-tree/soc/ranges")
|
|
|
|
defer ranges.Close()
|
2015-03-08 02:57:06 +01:00
|
|
|
if err != nil {
|
2015-03-08 03:45:00 +01:00
|
|
|
return
|
2015-03-08 02:57:06 +01:00
|
|
|
}
|
2015-03-08 03:45:00 +01:00
|
|
|
b := make([]byte, 4)
|
|
|
|
n, err := ranges.ReadAt(b, 4)
|
|
|
|
if n != 4 || err != nil {
|
|
|
|
return
|
2015-03-08 02:57:06 +01:00
|
|
|
}
|
2015-03-08 03:45:00 +01:00
|
|
|
buf := bytes.NewReader(b)
|
2015-03-08 03:53:00 +01:00
|
|
|
var out uint32
|
|
|
|
err = binary.Read(buf, binary.BigEndian, &out)
|
2015-03-08 03:45:00 +01:00
|
|
|
if err != nil {
|
|
|
|
return
|
2015-03-08 02:57:06 +01:00
|
|
|
}
|
2017-11-14 22:04:03 +01:00
|
|
|
return int64(out)
|
2015-03-08 02:57:06 +01:00
|
|
|
}
|