Golang interface for using the Silicon Labs CP2112 USB to SMBus/I2C bridge through its USB HID interface.
Depends on the go-hid package, which is based on the hidapi C interface.
- Download the pre-compiled hidapi release.
- Unzip to an easily accessible folder like
C:\usr\lib\hidapi
- Copy the
hidapi\include
folderhidapi\hidapi
- Set the two environment variables
CGO_CFLAGS
andCGO_LDFLAGS
as follows:$env:CGO_CFLAGS = "-IC:\usr\lib\hidapi-win-0.12.0 -g -O2"
$env:CGO_LDFLAGS = "-LC:\usr\lib\hidapi-win-0.12.0\x64 -g -O2"
- Check that the Go environment is properly updated with the
go env
command. - Copy the
hidapi\x64\hidapi.dll
to your current working directory, or somewhere that is accessible from thePATH
variable.
To unset an PowerShell environment variable:
$env:CGO_FLAGS = $null