Documentation ¶
Overview ¶
Abstraction module for gousb library.
Index ¶
- Constants
- func NewContext() *gousb.Context
- type AltOpts
- type AltPins
- type Data
- type ID
- type MCP
- func (micro *MCP) AutoDetach()
- func (micro *MCP) CalcHLBytes(baud string) (high, low uint8)
- func (micro *MCP) ClaimHIDInterface() *gousb.Interface
- func (micro *MCP) ConfigCmd() int
- func (micro *MCP) GetBaudRate(high, low uint8) int
- func (micro *MCP) GetBaudRateIndex(input string) int
- func (micro *MCP) InEndpoint() *gousb.InEndpoint
- func (micro *MCP) NewReqData() []byte
- func (micro *MCP) OpenDevice(VendID, ProdID ID) *gousb.Device
- func (micro *MCP) OutEndpoint() *gousb.OutEndpoint
- func (micro *MCP) ParseAltOpts(bitmap uint8) *AltOpts
- func (micro *MCP) ParseAltPins(bitmap uint8) *AltPins
- func (micro *MCP) ParseResponse() *Data
- func (micro *MCP) ReadAllCmd() int
- func (micro *MCP) ReadManufacturer() string
- func (micro *MCP) ReadProduct() string
- func (micro *MCP) ReadSerial() string
- func (micro *MCP) Reload() bool
- func (micro *MCP) SelectConfig() *gousb.Config
Constants ¶
const ( BASE_CONFIGURE = 0x01 SET_CLEAR_OUT = 0x08 CONFIGURE = 0x10 READ_EEPROM = 0x20 WRITE_EEPROM = 0x40 READ_ALL = 0x80 )
define command opcodes for MCP2200
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Data ¶
type Data struct { OpCmd uint8 EEP_Addr uint8 Reserved1 uint8 EEP_Val uint8 IO_Bmap uint8 Alt_Pins uint8 IO_Default uint8 Alt_Opts uint8 Baud_Rate_H uint8 Baud_Rate_L uint8 IO_Port_Val uint8 }
Represents configuration data from READ_ALL and CONFIGURE opcode commands.
type MCP ¶
type MCP struct { Context *gousb.Context Device *gousb.Device Conf *gousb.Config Interface *gousb.Interface InEP *gousb.InEndpoint OutEP *gousb.OutEndpoint VendID ID ProdID ID *Data }
MCP struct represents all the data structures to interact with the USB device.
func (*MCP) AutoDetach ¶
func (micro *MCP) AutoDetach()
Enables/disables automatic kernel driver detachment.
func (*MCP) CalcHLBytes ¶
Calculates high/low byte values.
func (*MCP) ClaimHIDInterface ¶
Claims the specified HID interface using a convenience function. The default interface is always #0 alt #0 in the currently active config.
func (*MCP) GetBaudRateIndex ¶
Returns active baud rate index
func (*MCP) InEndpoint ¶
func (micro *MCP) InEndpoint() *gousb.InEndpoint
Prepares an IN endpoint for transfer.
func (*MCP) NewReqData ¶
Creates new request data for CONFIGURE command.
func (*MCP) OpenDevice ¶
Opens any device with a given VID/PID using a convenience function.
func (*MCP) OutEndpoint ¶
func (micro *MCP) OutEndpoint() *gousb.OutEndpoint
Prepares an OUT endpoint for transfer.
func (*MCP) ParseAltOpts ¶
Parses Alt_Opts bitmap.
func (*MCP) ParseAltPins ¶
Parses Alt_Pins bitmap.
func (*MCP) ParseResponse ¶
Parses READ_ALL command response.
func (*MCP) ReadManufacturer ¶
Reads device manufacturer information.
func (*MCP) SelectConfig ¶
Select the device configuration number 0.