build: upgrade periph.io dependencies
This commit is contained in:
48
vendor/periph.io/x/d2xx/.gohci.yml
generated
vendored
Normal file
48
vendor/periph.io/x/d2xx/.gohci.yml
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
# Copyright 2021 The Periph Authors. All rights reserved.
|
||||
# Use of this source code is governed under the Apache License, Version 2.0
|
||||
# that can be found in the LICENSE file.
|
||||
|
||||
# See https://github.com/periph/gohci
|
||||
version: 1
|
||||
workers:
|
||||
- checks:
|
||||
- cmd:
|
||||
- go
|
||||
- test
|
||||
- ./...
|
||||
# Test in advance.
|
||||
- cmd:
|
||||
- git
|
||||
- clone
|
||||
- --depth
|
||||
- 1
|
||||
- https://github.com/periph/host
|
||||
dir: ..
|
||||
- cmd:
|
||||
- go
|
||||
- get
|
||||
- periph.io/x/d2xx@${GIT_SHA}
|
||||
dir: ../host
|
||||
- cmd:
|
||||
- go
|
||||
- test
|
||||
- ./...
|
||||
dir: ../host
|
||||
# Test in advance.
|
||||
- cmd:
|
||||
- git
|
||||
- clone
|
||||
- --depth
|
||||
- 1
|
||||
- https://github.com/periph/cmd
|
||||
dir: ..
|
||||
- cmd:
|
||||
- go
|
||||
- get
|
||||
- periph.io/x/d2xx@${GIT_SHA}
|
||||
dir: ../cmd
|
||||
- cmd:
|
||||
- go
|
||||
- test
|
||||
- ./...
|
||||
dir: ../cmd
|
202
vendor/periph.io/x/d2xx/LICENSE
generated
vendored
Normal file
202
vendor/periph.io/x/d2xx/LICENSE
generated
vendored
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
16
vendor/periph.io/x/d2xx/README.md
generated
vendored
Normal file
16
vendor/periph.io/x/d2xx/README.md
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
# d2xx
|
||||
|
||||
Package d2xx is a thin Go wrapper for the Future Technology "D2XX" driver at
|
||||
https://ftdichip.com/drivers/d2xx-drivers/.
|
||||
|
||||
See https://periph.io/device/ftdi/ for more details, and how to configure
|
||||
the host to be able to use this driver.
|
||||
|
||||
This package is not Go idiomatic. You will want to use
|
||||
https://periph.io/x/host/v3/ftdi (or later) instead.
|
||||
|
||||
But if you really want, here it goes:
|
||||
[](https://pkg.go.dev/periph.io/x/d2xx)
|
||||
|
||||
This Go package includes third party software. See
|
||||
[third_party/README.md](third_party/README.md).
|
132
vendor/periph.io/x/d2xx/d2xx.go
generated
vendored
Normal file
132
vendor/periph.io/x/d2xx/d2xx.go
generated
vendored
Normal file
@ -0,0 +1,132 @@
|
||||
// Copyright 2021 The Periph Authors. All rights reserved.
|
||||
// Use of this source code is governed under the Apache License, Version 2.0
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
package d2xx
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Err is the error type returned by d2xx functions.
|
||||
type Err int
|
||||
|
||||
// These are additional synthetic error codes.
|
||||
const (
|
||||
// NoCGO is returned when the package was compiled without cgo, thus the d2xx
|
||||
// library is unavailable.
|
||||
//
|
||||
// This is never returned on Windows.
|
||||
NoCGO Err = -2
|
||||
// Missing is returned when the dynamic library is not available.
|
||||
Missing Err = -1
|
||||
)
|
||||
|
||||
// String converts a error integer to a string representation of the error.
|
||||
func (e Err) String() string {
|
||||
switch e {
|
||||
case Missing:
|
||||
// when the library d2xx couldn't be loaded at runtime.
|
||||
return "couldn't load driver; visit https://periph.io/device/ftdi/ for help"
|
||||
case NoCGO:
|
||||
return "can't be used without cgo"
|
||||
case 0: // FT_OK
|
||||
return ""
|
||||
case 1: // FT_INVALID_HANDLE
|
||||
return "invalid handle"
|
||||
case 2: // FT_DEVICE_NOT_FOUND
|
||||
return "device not found; see https://periph.io/device/ftdi/ for help"
|
||||
case 3: // FT_DEVICE_NOT_OPENED
|
||||
return "device busy; see https://periph.io/device/ftdi/ for help"
|
||||
case 4: // FT_IO_ERROR
|
||||
return "I/O error"
|
||||
case 5: // FT_INSUFFICIENT_RESOURCES
|
||||
return "insufficient resources"
|
||||
case 6: // FT_INVALID_PARAMETER
|
||||
return "invalid parameter"
|
||||
case 7: // FT_INVALID_BAUD_RATE
|
||||
return "invalid baud rate"
|
||||
case 8: // FT_DEVICE_NOT_OPENED_FOR_ERASE
|
||||
return "device not opened for erase"
|
||||
case 9: // FT_DEVICE_NOT_OPENED_FOR_WRITE
|
||||
return "device not opened for write"
|
||||
case 10: // FT_FAILED_TO_WRITE_DEVICE
|
||||
return "failed to write device"
|
||||
case 11: // FT_EEPROM_READ_FAILED
|
||||
return "eeprom read failed"
|
||||
case 12: // FT_EEPROM_WRITE_FAILED
|
||||
return "eeprom write failed"
|
||||
case 13: // FT_EEPROM_ERASE_FAILED
|
||||
return "eeprom erase failed"
|
||||
case 14: // FT_EEPROM_NOT_PRESENT
|
||||
return "eeprom not present"
|
||||
case 15: // FT_EEPROM_NOT_PROGRAMMED
|
||||
return "eeprom not programmed"
|
||||
case 16: // FT_INVALID_ARGS
|
||||
return "invalid argument"
|
||||
case 17: // FT_NOT_SUPPORTED
|
||||
return "not supported"
|
||||
case 18: // FT_OTHER_ERROR
|
||||
return "other error"
|
||||
case 19: // FT_DEVICE_LIST_NOT_READY
|
||||
return "device list not ready"
|
||||
default:
|
||||
return "unknown status " + strconv.Itoa(int(e))
|
||||
}
|
||||
}
|
||||
|
||||
// unknown is a forward declaration of ftdi.DevType.
|
||||
const unknown = 3
|
||||
|
||||
// handle is a d2xx handle.
|
||||
//
|
||||
// This is the base type which each OS specific implementation adds methods to.
|
||||
type handle uintptr
|
||||
|
||||
// Handle is d2xx device handle.
|
||||
type Handle interface {
|
||||
Close() Err
|
||||
// ResetDevice takes >1.2ms
|
||||
ResetDevice() Err
|
||||
GetDeviceInfo() (uint32, uint16, uint16, Err)
|
||||
EEPROMRead(devType uint32, e *EEPROM) Err
|
||||
EEPROMProgram(e *EEPROM) Err
|
||||
EraseEE() Err
|
||||
WriteEE(offset uint8, value uint16) Err
|
||||
EEUASize() (int, Err)
|
||||
EEUARead(ua []byte) Err
|
||||
EEUAWrite(ua []byte) Err
|
||||
SetChars(eventChar byte, eventEn bool, errorChar byte, errorEn bool) Err
|
||||
SetUSBParameters(in, out int) Err
|
||||
SetFlowControl() Err
|
||||
SetTimeouts(readMS, writeMS int) Err
|
||||
SetLatencyTimer(delayMS uint8) Err
|
||||
SetBaudRate(hz uint32) Err
|
||||
// GetQueueStatus takes >60µs
|
||||
GetQueueStatus() (uint32, Err)
|
||||
// Read takes <5µs if GetQueueStatus was called just before,
|
||||
// 300µs~800µs otherwise (!)
|
||||
Read(b []byte) (int, Err)
|
||||
// Write takes >0.1ms
|
||||
Write(b []byte) (int, Err)
|
||||
GetBitMode() (byte, Err)
|
||||
// SetBitMode takes >0.1ms
|
||||
SetBitMode(mask, mode byte) Err
|
||||
}
|
||||
|
||||
var _ Handle = handle(0)
|
||||
|
||||
// Version returns the library's version.
|
||||
func Version() (uint8, uint8, uint8) {
|
||||
return version()
|
||||
}
|
||||
|
||||
// CreateDeviceInfoList discovers the currently found devices.
|
||||
func CreateDeviceInfoList() (int, Err) {
|
||||
return createDeviceInfoList()
|
||||
}
|
||||
|
||||
// Open opens the ith device discovered.
|
||||
func Open(i int) (Handle, Err) {
|
||||
return open(i)
|
||||
}
|
12
vendor/periph.io/x/d2xx/d2xx_darwin_amd64.go
generated
vendored
Normal file
12
vendor/periph.io/x/d2xx/d2xx_darwin_amd64.go
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright 2017 The Periph Authors. All rights reserved.
|
||||
// Use of this source code is governed under the Apache License, Version 2.0
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
// +build cgo
|
||||
|
||||
package d2xx
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -framework CoreFoundation -framework IOKit ${SRCDIR}/third_party/libftd2xx_darwin_amd64_v1.4.4.a
|
||||
*/
|
||||
import "C"
|
12
vendor/periph.io/x/d2xx/d2xx_linux_amd64.go
generated
vendored
Normal file
12
vendor/periph.io/x/d2xx/d2xx_linux_amd64.go
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright 2017 The Periph Authors. All rights reserved.
|
||||
// Use of this source code is governed under the Apache License, Version 2.0
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
// +build cgo
|
||||
|
||||
package d2xx
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: ${SRCDIR}/third_party/libftd2xx_linux_amd64_v1.4.6.a
|
||||
*/
|
||||
import "C"
|
15
vendor/periph.io/x/d2xx/d2xx_linux_arm.go
generated
vendored
Normal file
15
vendor/periph.io/x/d2xx/d2xx_linux_arm.go
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2017 The Periph Authors. All rights reserved.
|
||||
// Use of this source code is governed under the Apache License, Version 2.0
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
// +build cgo
|
||||
|
||||
package d2xx
|
||||
|
||||
// TODO(maruel): https://github.com/golang/go/issues/7211 would help target the
|
||||
// optimal ARM architecture.
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: ${SRCDIR}/third_party/libftd2xx_linux_arm6hf_v1.4.6.a
|
||||
*/
|
||||
import "C"
|
217
vendor/periph.io/x/d2xx/d2xx_posix.go
generated
vendored
Normal file
217
vendor/periph.io/x/d2xx/d2xx_posix.go
generated
vendored
Normal file
@ -0,0 +1,217 @@
|
||||
// Copyright 2017 The Periph Authors. All rights reserved.
|
||||
// Use of this source code is governed under the Apache License, Version 2.0
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
// +build !windows
|
||||
|
||||
package d2xx
|
||||
|
||||
/*
|
||||
#include "third_party/ftd2xx.h"
|
||||
#include <stdlib.h>
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// Available is true if the library is available on this system.
|
||||
const Available = true
|
||||
|
||||
// Library functions.
|
||||
|
||||
func version() (uint8, uint8, uint8) {
|
||||
var v C.DWORD
|
||||
C.FT_GetLibraryVersion(&v)
|
||||
return uint8(v >> 16), uint8(v >> 8), uint8(v)
|
||||
}
|
||||
|
||||
func createDeviceInfoList() (int, Err) {
|
||||
var num C.DWORD
|
||||
e := C.FT_CreateDeviceInfoList(&num)
|
||||
return int(num), Err(e)
|
||||
}
|
||||
|
||||
func open(i int) (Handle, Err) {
|
||||
var h C.FT_HANDLE
|
||||
e := C.FT_Open(C.int(i), &h)
|
||||
if uintptr(h) == 0 && e == 0 {
|
||||
// 18 means FT_OTHER_ERROR. Kind of a hack but better than panic.
|
||||
e = 18
|
||||
}
|
||||
return handle(h), Err(e)
|
||||
}
|
||||
|
||||
func (h handle) Close() Err {
|
||||
return Err(C.FT_Close(h.toH()))
|
||||
}
|
||||
|
||||
func (h handle) ResetDevice() Err {
|
||||
return Err(C.FT_ResetDevice(h.toH()))
|
||||
}
|
||||
|
||||
func (h handle) GetDeviceInfo() (uint32, uint16, uint16, Err) {
|
||||
var dev C.FT_DEVICE
|
||||
var id C.DWORD
|
||||
if e := C.FT_GetDeviceInfo(h.toH(), &dev, &id, nil, nil, nil); e != 0 {
|
||||
return unknown, 0, 0, Err(e)
|
||||
}
|
||||
return uint32(dev), uint16(id >> 16), uint16(id), 0
|
||||
}
|
||||
|
||||
func (h handle) EEPROMRead(devType uint32, ee *EEPROM) Err {
|
||||
var manufacturer [64]C.char
|
||||
var manufacturerID [64]C.char
|
||||
var desc [64]C.char
|
||||
var serial [64]C.char
|
||||
eepromVoid := unsafe.Pointer(&ee.Raw[0])
|
||||
hdr := ee.asHeader()
|
||||
|
||||
// There something odd going on here.
|
||||
//
|
||||
// On a ft232h, we observed that hdr.DeviceType MUST NOT be set, but on a
|
||||
// ft232r, it MUST be set. Since we can't know in advance what we must use,
|
||||
// just try both. ¯\_(ツ)_/¯
|
||||
hdr.DeviceType = devType
|
||||
if e := C.FT_EEPROM_Read(h.toH(), eepromVoid, C.DWORD(len(ee.Raw)), &manufacturer[0], &manufacturerID[0], &desc[0], &serial[0]); e != 0 {
|
||||
// FT_INVALID_PARAMETER
|
||||
if e == 6 {
|
||||
hdr.DeviceType = 0
|
||||
e = C.FT_EEPROM_Read(h.toH(), eepromVoid, C.DWORD(len(ee.Raw)), &manufacturer[0], &manufacturerID[0], &desc[0], &serial[0])
|
||||
}
|
||||
if e != 0 {
|
||||
return Err(e)
|
||||
}
|
||||
}
|
||||
|
||||
ee.Manufacturer = C.GoString(&manufacturer[0])
|
||||
ee.ManufacturerID = C.GoString(&manufacturerID[0])
|
||||
ee.Desc = C.GoString(&desc[0])
|
||||
ee.Serial = C.GoString(&serial[0])
|
||||
return 0
|
||||
}
|
||||
|
||||
func (h handle) EEPROMProgram(ee *EEPROM) Err {
|
||||
// len(manufacturer) + len(desc) <= 40.
|
||||
/*
|
||||
var cmanu [64]byte
|
||||
copy(cmanu[:], ee.manufacturer)
|
||||
var cmanuID [64]byte
|
||||
copy(cmanuID[:], ee.manufacturerID)
|
||||
var cdesc [64]byte
|
||||
copy(cdesc[:], ee.desc)
|
||||
var cserial [64]byte
|
||||
copy(cserial[:], ee.serial)
|
||||
*/
|
||||
cmanu := C.CString(ee.Manufacturer)
|
||||
defer C.free(unsafe.Pointer(cmanu))
|
||||
cmanuID := C.CString(ee.ManufacturerID)
|
||||
defer C.free(unsafe.Pointer(cmanuID))
|
||||
cdesc := C.CString(ee.Desc)
|
||||
defer C.free(unsafe.Pointer(cdesc))
|
||||
cserial := C.CString(ee.Serial)
|
||||
defer C.free(unsafe.Pointer(cserial))
|
||||
|
||||
if len(ee.Raw) == 0 {
|
||||
return Err(C.FT_EEPROM_Program(h.toH(), unsafe.Pointer(uintptr(0)), 0, cmanu, cmanuID, cdesc, cserial))
|
||||
}
|
||||
return Err(C.FT_EEPROM_Program(h.toH(), unsafe.Pointer(&ee.Raw[0]), C.DWORD(len(ee.Raw)), cmanu, cmanuID, cdesc, cserial))
|
||||
}
|
||||
|
||||
func (h handle) EraseEE() Err {
|
||||
return Err(C.FT_EraseEE(h.toH()))
|
||||
}
|
||||
|
||||
func (h handle) WriteEE(offset uint8, value uint16) Err {
|
||||
return Err(C.FT_WriteEE(h.toH(), C.DWORD(offset), C.WORD(value)))
|
||||
}
|
||||
|
||||
func (h handle) EEUASize() (int, Err) {
|
||||
var size C.DWORD
|
||||
if e := C.FT_EE_UASize(h.toH(), &size); e != 0 {
|
||||
return 0, Err(e)
|
||||
}
|
||||
return int(size), 0
|
||||
}
|
||||
|
||||
func (h handle) EEUARead(ua []byte) Err {
|
||||
var size C.DWORD
|
||||
if e := C.FT_EE_UARead(h.toH(), (*C.UCHAR)(unsafe.Pointer(&ua[0])), C.DWORD(len(ua)), &size); e != 0 {
|
||||
return Err(e)
|
||||
}
|
||||
if int(size) != len(ua) {
|
||||
return 6 // FT_INVALID_PARAMETER
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (h handle) EEUAWrite(ua []byte) Err {
|
||||
if e := C.FT_EE_UAWrite(h.toH(), (*C.UCHAR)(&ua[0]), C.DWORD(len(ua))); e != 0 {
|
||||
return Err(e)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (h handle) SetChars(eventChar byte, eventEn bool, errorChar byte, errorEn bool) Err {
|
||||
v := C.UCHAR(0)
|
||||
if eventEn {
|
||||
v = 1
|
||||
}
|
||||
w := C.UCHAR(0)
|
||||
if errorEn {
|
||||
w = 1
|
||||
}
|
||||
return Err(C.FT_SetChars(h.toH(), C.UCHAR(eventChar), v, C.UCHAR(errorChar), w))
|
||||
}
|
||||
|
||||
func (h handle) SetUSBParameters(in, out int) Err {
|
||||
return Err(C.FT_SetUSBParameters(h.toH(), C.DWORD(in), C.DWORD(out)))
|
||||
}
|
||||
|
||||
func (h handle) SetFlowControl() Err {
|
||||
return Err(C.FT_SetFlowControl(h.toH(), C.FT_FLOW_RTS_CTS, 0, 0))
|
||||
}
|
||||
|
||||
func (h handle) SetTimeouts(readMS, writeMS int) Err {
|
||||
return Err(C.FT_SetTimeouts(h.toH(), C.DWORD(readMS), C.DWORD(writeMS)))
|
||||
}
|
||||
|
||||
func (h handle) SetLatencyTimer(delayMS uint8) Err {
|
||||
return Err(C.FT_SetLatencyTimer(h.toH(), C.UCHAR(delayMS)))
|
||||
}
|
||||
|
||||
func (h handle) SetBaudRate(hz uint32) Err {
|
||||
return Err(C.FT_SetBaudRate(h.toH(), C.DWORD(hz)))
|
||||
}
|
||||
|
||||
func (h handle) GetQueueStatus() (uint32, Err) {
|
||||
var v C.DWORD
|
||||
e := C.FT_GetQueueStatus(h.toH(), &v)
|
||||
return uint32(v), Err(e)
|
||||
}
|
||||
|
||||
func (h handle) Read(b []byte) (int, Err) {
|
||||
var bytesRead C.DWORD
|
||||
e := C.FT_Read(h.toH(), C.LPVOID(unsafe.Pointer(&b[0])), C.DWORD(len(b)), &bytesRead)
|
||||
return int(bytesRead), Err(e)
|
||||
}
|
||||
|
||||
func (h handle) Write(b []byte) (int, Err) {
|
||||
var bytesSent C.DWORD
|
||||
e := C.FT_Write(h.toH(), C.LPVOID(unsafe.Pointer(&b[0])), C.DWORD(len(b)), &bytesSent)
|
||||
return int(bytesSent), Err(e)
|
||||
}
|
||||
|
||||
func (h handle) GetBitMode() (byte, Err) {
|
||||
var s C.UCHAR
|
||||
e := C.FT_GetBitMode(h.toH(), &s)
|
||||
return uint8(s), Err(e)
|
||||
}
|
||||
|
||||
func (h handle) SetBitMode(mask, mode byte) Err {
|
||||
return Err(C.FT_SetBitMode(h.toH(), C.UCHAR(mask), C.UCHAR(mode)))
|
||||
}
|
||||
|
||||
func (h handle) toH() C.FT_HANDLE {
|
||||
return C.FT_HANDLE(h)
|
||||
}
|
109
vendor/periph.io/x/d2xx/d2xx_posix_no_cgo.go
generated
vendored
Normal file
109
vendor/periph.io/x/d2xx/d2xx_posix_no_cgo.go
generated
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
// Copyright 2017 The Periph Authors. All rights reserved.
|
||||
// Use of this source code is governed under the Apache License, Version 2.0
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
// +build !cgo
|
||||
// +build !windows
|
||||
|
||||
package d2xx
|
||||
|
||||
// Available is true if the library is available on this system.
|
||||
const Available = false
|
||||
|
||||
// Library functions.
|
||||
|
||||
func version() (uint8, uint8, uint8) {
|
||||
return 0, 0, 0
|
||||
}
|
||||
|
||||
func createDeviceInfoList() (int, Err) {
|
||||
return 0, NoCGO
|
||||
}
|
||||
|
||||
func open(i int) (Handle, Err) {
|
||||
return handle(0), NoCGO
|
||||
}
|
||||
|
||||
func (h handle) Close() Err {
|
||||
return NoCGO
|
||||
}
|
||||
|
||||
func (h handle) ResetDevice() Err {
|
||||
return NoCGO
|
||||
}
|
||||
|
||||
func (h handle) GetDeviceInfo() (uint32, uint16, uint16, Err) {
|
||||
return unknown, 0, 0, NoCGO
|
||||
}
|
||||
|
||||
func (h handle) EEPROMRead(devType uint32, ee *EEPROM) Err {
|
||||
return NoCGO
|
||||
}
|
||||
|
||||
func (h handle) EEPROMProgram(e *EEPROM) Err {
|
||||
return NoCGO
|
||||
}
|
||||
|
||||
func (h handle) EraseEE() Err {
|
||||
return NoCGO
|
||||
}
|
||||
|
||||
func (h handle) WriteEE(offset uint8, value uint16) Err {
|
||||
return NoCGO
|
||||
}
|
||||
|
||||
func (h handle) EEUASize() (int, Err) {
|
||||
return 0, NoCGO
|
||||
}
|
||||
|
||||
func (h handle) EEUARead(ua []byte) Err {
|
||||
return NoCGO
|
||||
}
|
||||
|
||||
func (h handle) EEUAWrite(ua []byte) Err {
|
||||
return NoCGO
|
||||
}
|
||||
|
||||
func (h handle) SetChars(eventChar byte, eventEn bool, errorChar byte, errorEn bool) Err {
|
||||
return NoCGO
|
||||
}
|
||||
|
||||
func (h handle) SetUSBParameters(in, out int) Err {
|
||||
return NoCGO
|
||||
}
|
||||
|
||||
func (h handle) SetFlowControl() Err {
|
||||
return NoCGO
|
||||
}
|
||||
|
||||
func (h handle) SetTimeouts(readMS, writeMS int) Err {
|
||||
return NoCGO
|
||||
}
|
||||
|
||||
func (h handle) SetLatencyTimer(delayMS uint8) Err {
|
||||
return NoCGO
|
||||
}
|
||||
|
||||
func (h handle) SetBaudRate(hz uint32) Err {
|
||||
return NoCGO
|
||||
}
|
||||
|
||||
func (h handle) GetQueueStatus() (uint32, Err) {
|
||||
return 0, NoCGO
|
||||
}
|
||||
|
||||
func (h handle) Read(b []byte) (int, Err) {
|
||||
return 0, NoCGO
|
||||
}
|
||||
|
||||
func (h handle) Write(b []byte) (int, Err) {
|
||||
return 0, NoCGO
|
||||
}
|
||||
|
||||
func (h handle) GetBitMode() (byte, Err) {
|
||||
return 0, NoCGO
|
||||
}
|
||||
|
||||
func (h handle) SetBitMode(mask, mode byte) Err {
|
||||
return NoCGO
|
||||
}
|
16
vendor/periph.io/x/d2xx/d2xx_posix_other.go
generated
vendored
Normal file
16
vendor/periph.io/x/d2xx/d2xx_posix_other.go
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2017 The Periph Authors. All rights reserved.
|
||||
// Use of this source code is governed under the Apache License, Version 2.0
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
// +build cgo
|
||||
// +build !darwin,!amd64
|
||||
// +build !linux,!amd64
|
||||
// +build !linux,!arm
|
||||
// +build !windows
|
||||
|
||||
package d2xx
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -lftd2xx
|
||||
*/
|
||||
import "C"
|
273
vendor/periph.io/x/d2xx/d2xx_windows.go
generated
vendored
Normal file
273
vendor/periph.io/x/d2xx/d2xx_windows.go
generated
vendored
Normal file
@ -0,0 +1,273 @@
|
||||
// Copyright 2017 The Periph Authors. All rights reserved.
|
||||
// Use of this source code is governed under the Apache License, Version 2.0
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
package d2xx
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// Available is true if the library is available on this system.
|
||||
var Available = false
|
||||
|
||||
func version() (uint8, uint8, uint8) {
|
||||
var v uint32
|
||||
if pGetLibraryVersion != nil {
|
||||
_, _, _ = pGetLibraryVersion.Call(uintptr(unsafe.Pointer(&v)))
|
||||
}
|
||||
return uint8(v >> 16), uint8(v >> 8), uint8(v)
|
||||
}
|
||||
|
||||
func createDeviceInfoList() (int, Err) {
|
||||
var num uint32
|
||||
r1, _, _ := pCreateDeviceInfoList.Call(uintptr(unsafe.Pointer(&num)))
|
||||
return int(num), Err(r1)
|
||||
}
|
||||
|
||||
func open(i int) (Handle, Err) {
|
||||
var h handle
|
||||
r1, _, _ := pOpen.Call(uintptr(i), uintptr(unsafe.Pointer(&h)))
|
||||
return h, Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) Close() Err {
|
||||
r1, _, _ := pClose.Call(h.toH())
|
||||
return Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) ResetDevice() Err {
|
||||
r1, _, _ := pResetDevice.Call(h.toH())
|
||||
return Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) GetDeviceInfo() (uint32, uint16, uint16, Err) {
|
||||
var d uint32
|
||||
var id uint32
|
||||
if r1, _, _ := pGetDeviceInfo.Call(h.toH(), uintptr(unsafe.Pointer(&d)), uintptr(unsafe.Pointer(&id)), 0, 0, 0); r1 != 0 {
|
||||
return unknown, 0, 0, Err(r1)
|
||||
}
|
||||
return d, uint16(id >> 16), uint16(id), 0
|
||||
}
|
||||
|
||||
func (h handle) EEPROMRead(devType uint32, ee *EEPROM) Err {
|
||||
var manufacturer [64]byte
|
||||
var manufacturerID [64]byte
|
||||
var desc [64]byte
|
||||
var serial [64]byte
|
||||
// Shortcuts.
|
||||
m := uintptr(unsafe.Pointer(&manufacturer[0]))
|
||||
mi := uintptr(unsafe.Pointer(&manufacturerID[0]))
|
||||
de := uintptr(unsafe.Pointer(&desc[0]))
|
||||
s := uintptr(unsafe.Pointer(&serial[0]))
|
||||
|
||||
eepromVoid := unsafe.Pointer(&ee.Raw[0])
|
||||
hdr := ee.asHeader()
|
||||
// It MUST be set here. This is not always the case on posix.
|
||||
hdr.DeviceType = devType
|
||||
if r1, _, _ := pEEPROMRead.Call(h.toH(), uintptr(eepromVoid), uintptr(len(ee.Raw)), m, mi, de, s); r1 != 0 {
|
||||
return Err(r1)
|
||||
}
|
||||
|
||||
ee.Manufacturer = toStr(manufacturer[:])
|
||||
ee.ManufacturerID = toStr(manufacturerID[:])
|
||||
ee.Desc = toStr(desc[:])
|
||||
ee.Serial = toStr(serial[:])
|
||||
return 0
|
||||
}
|
||||
|
||||
func (h handle) EEPROMProgram(ee *EEPROM) Err {
|
||||
var cmanu [64]byte
|
||||
copy(cmanu[:], ee.Manufacturer)
|
||||
var cmanuID [64]byte
|
||||
copy(cmanuID[:], ee.ManufacturerID)
|
||||
var cdesc [64]byte
|
||||
copy(cdesc[:], ee.Desc)
|
||||
var cserial [64]byte
|
||||
copy(cserial[:], ee.Serial)
|
||||
r1, _, _ := pEEPROMProgram.Call(h.toH(), uintptr(unsafe.Pointer(&ee.Raw[0])), uintptr(len(ee.Raw)), uintptr(unsafe.Pointer(&cmanu[0])), uintptr(unsafe.Pointer(&cmanuID[0])), uintptr(unsafe.Pointer(&cdesc[0])), uintptr(unsafe.Pointer(&cserial[0])))
|
||||
return Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) EraseEE() Err {
|
||||
r1, _, _ := pEraseEE.Call(h.toH())
|
||||
return Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) WriteEE(offset uint8, value uint16) Err {
|
||||
r1, _, _ := pWriteEE.Call(h.toH(), uintptr(offset), uintptr(value))
|
||||
return Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) EEUASize() (int, Err) {
|
||||
var size uint32
|
||||
if r1, _, _ := pEEUASize.Call(h.toH(), uintptr(unsafe.Pointer(&size))); r1 != 0 {
|
||||
return 0, Err(r1)
|
||||
}
|
||||
return int(size), 0
|
||||
}
|
||||
|
||||
func (h handle) EEUARead(ua []byte) Err {
|
||||
var size uint32
|
||||
if r1, _, _ := pEEUARead.Call(h.toH(), uintptr(unsafe.Pointer(&ua[0])), uintptr(len(ua)), uintptr(unsafe.Pointer(&size))); r1 != 0 {
|
||||
return Err(r1)
|
||||
}
|
||||
if int(size) != len(ua) {
|
||||
return 6 // FT_INVALID_PARAMETER
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (h handle) EEUAWrite(ua []byte) Err {
|
||||
r1, _, _ := pEEUAWrite.Call(h.toH(), uintptr(unsafe.Pointer(&ua[0])), uintptr(len(ua)))
|
||||
return Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) SetChars(eventChar byte, eventEn bool, errorChar byte, errorEn bool) Err {
|
||||
v := uintptr(0)
|
||||
if eventEn {
|
||||
v = 1
|
||||
}
|
||||
w := uintptr(0)
|
||||
if errorEn {
|
||||
w = 1
|
||||
}
|
||||
r1, _, _ := pSetChars.Call(h.toH(), uintptr(eventChar), v, uintptr(errorChar), w)
|
||||
return Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) SetUSBParameters(in, out int) Err {
|
||||
r1, _, _ := pSetUSBParameters.Call(h.toH(), uintptr(in), uintptr(out))
|
||||
return Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) SetFlowControl() Err {
|
||||
// FT_FLOW_RTS_CTS
|
||||
r1, _, _ := pSetFlowControl.Call(h.toH(), 0x0100, 0, 0)
|
||||
return Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) SetTimeouts(readMS, writeMS int) Err {
|
||||
r1, _, _ := pSetTimeouts.Call(h.toH(), uintptr(readMS), uintptr(writeMS))
|
||||
return Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) SetLatencyTimer(delayMS uint8) Err {
|
||||
r1, _, _ := pSetLatencyTimer.Call(h.toH(), uintptr(delayMS))
|
||||
return Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) SetBaudRate(hz uint32) Err {
|
||||
r1, _, _ := pSetBaudRate.Call(h.toH(), uintptr(hz))
|
||||
return Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) GetQueueStatus() (uint32, Err) {
|
||||
var v uint32
|
||||
r1, _, _ := pGetQueueStatus.Call(h.toH(), uintptr(unsafe.Pointer(&v)))
|
||||
return v, Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) Read(b []byte) (int, Err) {
|
||||
var bytesRead uint32
|
||||
r1, _, _ := pRead.Call(h.toH(), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), uintptr(unsafe.Pointer(&bytesRead)))
|
||||
return int(bytesRead), Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) Write(b []byte) (int, Err) {
|
||||
var bytesSent uint32
|
||||
r1, _, _ := pWrite.Call(h.toH(), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), uintptr(unsafe.Pointer(&bytesSent)))
|
||||
return int(bytesSent), Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) GetBitMode() (byte, Err) {
|
||||
var s uint8
|
||||
r1, _, _ := pGetBitMode.Call(h.toH(), uintptr(unsafe.Pointer(&s)))
|
||||
return s, Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) SetBitMode(mask, mode byte) Err {
|
||||
r1, _, _ := pSetBitMode.Call(h.toH(), uintptr(mask), uintptr(mode))
|
||||
return Err(r1)
|
||||
}
|
||||
|
||||
func (h handle) toH() uintptr {
|
||||
return uintptr(h)
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
var (
|
||||
pClose *syscall.Proc
|
||||
pCreateDeviceInfoList *syscall.Proc
|
||||
pEEPROMRead *syscall.Proc
|
||||
pEEPROMProgram *syscall.Proc
|
||||
pEraseEE *syscall.Proc
|
||||
pWriteEE *syscall.Proc
|
||||
pEEUASize *syscall.Proc
|
||||
pEEUARead *syscall.Proc
|
||||
pEEUAWrite *syscall.Proc
|
||||
pGetBitMode *syscall.Proc
|
||||
pGetDeviceInfo *syscall.Proc
|
||||
pGetLibraryVersion *syscall.Proc
|
||||
pGetQueueStatus *syscall.Proc
|
||||
pOpen *syscall.Proc
|
||||
pRead *syscall.Proc
|
||||
pResetDevice *syscall.Proc
|
||||
pSetBaudRate *syscall.Proc
|
||||
pSetBitMode *syscall.Proc
|
||||
pSetChars *syscall.Proc
|
||||
pSetFlowControl *syscall.Proc
|
||||
pSetLatencyTimer *syscall.Proc
|
||||
pSetTimeouts *syscall.Proc
|
||||
pSetUSBParameters *syscall.Proc
|
||||
pWrite *syscall.Proc
|
||||
)
|
||||
|
||||
func init() {
|
||||
if dll, _ := syscall.LoadDLL("ftd2xx.dll"); dll != nil {
|
||||
// If any function is not found, disable the support.
|
||||
Available = true
|
||||
find := func(n string) *syscall.Proc {
|
||||
s, _ := dll.FindProc(n)
|
||||
if s == nil {
|
||||
Available = false
|
||||
}
|
||||
return s
|
||||
}
|
||||
pClose = find("FT_Close")
|
||||
pCreateDeviceInfoList = find("FT_CreateDeviceInfoList")
|
||||
pEEPROMRead = find("FT_EEPROM_Read")
|
||||
pEEPROMProgram = find("FT_EEPROM_Program")
|
||||
pEraseEE = find("FT_EraseEE")
|
||||
pWriteEE = find("FT_WriteEE")
|
||||
pEEUASize = find("FT_EE_UASize")
|
||||
pEEUARead = find("FT_EE_UARead")
|
||||
pEEUAWrite = find("FT_EE_UAWrite")
|
||||
pGetBitMode = find("FT_GetBitMode")
|
||||
pGetDeviceInfo = find("FT_GetDeviceInfo")
|
||||
pGetLibraryVersion = find("FT_GetLibraryVersion")
|
||||
pGetQueueStatus = find("FT_GetQueueStatus")
|
||||
pOpen = find("FT_Open")
|
||||
pRead = find("FT_Read")
|
||||
pResetDevice = find("FT_ResetDevice")
|
||||
pSetBaudRate = find("FT_SetBaudRate")
|
||||
pSetBitMode = find("FT_SetBitMode")
|
||||
pSetChars = find("FT_SetChars")
|
||||
pSetFlowControl = find("FT_SetFlowControl")
|
||||
pSetLatencyTimer = find("FT_SetLatencyTimer")
|
||||
pSetTimeouts = find("FT_SetTimeouts")
|
||||
pSetUSBParameters = find("FT_SetUSBParameters")
|
||||
pWrite = find("FT_Write")
|
||||
}
|
||||
}
|
||||
|
||||
func toStr(c []byte) string {
|
||||
i := bytes.IndexByte(c, 0)
|
||||
if i != -1 {
|
||||
return string(c[:i])
|
||||
}
|
||||
return string(c)
|
||||
}
|
21
vendor/periph.io/x/d2xx/doc.go
generated
vendored
Normal file
21
vendor/periph.io/x/d2xx/doc.go
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright 2017 The Periph Authors. All rights reserved.
|
||||
// Use of this source code is governed under the Apache License, Version 2.0
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
// Package d2xx is a thin Go wrapper for the Future Technology "D2XX" driver.
|
||||
//
|
||||
// This package is not Go idiomatic. You want to use
|
||||
// https://periph.io/x/host/v3/ftdi instead.
|
||||
//
|
||||
// A binary copy of the d2xx driver is included for linux and macOS. They are
|
||||
// from https://ftdichip.com/drivers/d2xx-drivers/. See third_party/README.md
|
||||
// for more details.
|
||||
//
|
||||
// Configuration
|
||||
//
|
||||
// See https://periph.io/device/ftdi/ for more details, and how to configure
|
||||
// the host to be able to use this driver.
|
||||
//
|
||||
// Windows 10 automatically fetches the driver from Windows Update upon
|
||||
// connecting a FTDI device on the firt time, so no need to download a driver.
|
||||
package d2xx
|
39
vendor/periph.io/x/d2xx/eeprom.go
generated
vendored
Normal file
39
vendor/periph.io/x/d2xx/eeprom.go
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
// Copyright 2018 The Periph Authors. All rights reserved.
|
||||
// Use of this source code is governed under the Apache License, Version 2.0
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
package d2xx
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// EEPROM is the unprocessed EEPROM content.
|
||||
//
|
||||
// The EEPROM is in 3 parts: the defined struct, the 4 strings and the rest
|
||||
// which is used as an 'user area'. The size of the user area depends on the
|
||||
// length of the strings. The user area content is not included in this struct.
|
||||
type EEPROM struct {
|
||||
// Raw is the raw EEPROM content. It excludes the strings.
|
||||
Raw []byte
|
||||
|
||||
// The following condition must be true: len(Manufacturer) + len(Desc) <= 40.
|
||||
Manufacturer string
|
||||
ManufacturerID string
|
||||
Desc string
|
||||
Serial string
|
||||
}
|
||||
|
||||
func (e *EEPROM) asHeader() *eepromHeader {
|
||||
// sizeof(EEPROMHeader)
|
||||
if len(e.Raw) < 16 {
|
||||
return nil
|
||||
}
|
||||
return (*eepromHeader)(unsafe.Pointer(&e.Raw[0]))
|
||||
}
|
||||
|
||||
// eepromHeader is the common 16 bytes header.
|
||||
type eepromHeader struct {
|
||||
DeviceType uint32
|
||||
// The rest is not necessary here so it is skipped.
|
||||
}
|
25
vendor/periph.io/x/d2xx/test.sh
generated
vendored
Normal file
25
vendor/periph.io/x/d2xx/test.sh
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2017 The Periph Authors. All rights reserved.
|
||||
# Use of this source code is governed under the Apache License, Version 2.0
|
||||
# that can be found in the LICENSE file.
|
||||
|
||||
# Builds the package on multiple OSes to confirm it builds fine.
|
||||
#
|
||||
# It is recommended to use the -i flag so subsequent runs are much faster.
|
||||
|
||||
set -eu
|
||||
|
||||
cd `dirname $0`
|
||||
|
||||
OPT=$*
|
||||
|
||||
function build {
|
||||
echo "Testing on $1/$2"
|
||||
GOOS=$1 GOARCH=$2 go build $OPT
|
||||
}
|
||||
|
||||
build darwin amd64
|
||||
build linux amd64
|
||||
build linux arm
|
||||
build linux 386
|
||||
build windows amd64
|
Reference in New Issue
Block a user