Documentation ¶
Index ¶
- Constants
- Variables
- type GPIODesignation
- type GPIOMode
- type MCP2221
- func (d *MCP2221) GetGPIOParameters(ctx context.Context) (MCP2221GPIOParameters, error)
- func (d *MCP2221) Init() error
- func (d *MCP2221) Read(ctx context.Context) ([]byte, error)
- func (d *MCP2221) ReadChipSettings(ctx context.Context) error
- func (d *MCP2221) ReadFromAddr(ctx context.Context, address byte, buffer []byte) error
- func (d *MCP2221) ReadGPIO(ctx context.Context) (MCP2221GPIOValues, error)
- func (d *MCP2221) ReadGPIOSettings(ctx context.Context) error
- func (d *MCP2221) Release(ctx context.Context) error
- func (d *MCP2221) ReleaseBus(ctx context.Context) (*MCP2221Status, error)
- func (d *MCP2221) Reset(ctx context.Context) error
- func (d *MCP2221) SetGPIOParameters(ctx context.Context, params MCP2221GPIOParameters) error
- func (d *MCP2221) SetVendorAndProductID(vendor, product uint16)
- func (d *MCP2221) Status(ctx context.Context) (*MCP2221Status, error)
- func (d *MCP2221) UpdateVendorAndProductID(ctx context.Context, vendor, product []byte, dryrun ...bool) error
- func (d *MCP2221) WriteToAddr(ctx context.Context, address byte, buffer []byte) error
- type MCP2221GPIOParameters
- type MCP2221GPIOValues
- type MCP2221Status
Constants ¶
View Source
const ( StatusNew = iota StatusInitialized StatusConnecting StatusConnected )
View Source
const ProductID = 0x00DD
View Source
const VendorID = 0x04D8
Variables ¶
View Source
var ErrCommandFailed = errors.New("command failed")
View Source
var ErrCommandUnsupported = errors.New("unsupported command")
View Source
var ErrI2CAddressMismatch = errors.New("i2c address mismatch")
View Source
var ErrI2CStatusTimeout = errors.New("i2c status check timeout")
View Source
var ErrNoReconnectChannel = errors.New("reconnect channel not initialized")
View Source
var ErrNotConnected = errors.New("not connected")
Functions ¶
This section is empty.
Types ¶
type GPIODesignation ¶ added in v0.3.0
type GPIODesignation byte
const ( GPIOOperation GPIODesignation = 0b00000000 // GPIO0LedUartRx This is alternate function of GPIO0 GPIO0LedUartRx GPIODesignation = 0b00000001 // GPIO0SSPND This is the dedicated function operation of GPIO0 GPIO0SSPND GPIODesignation = 0b00000010 // GPIO1ClockOutput This is the dedicated function of GPIO1 GPIO1ClockOutput GPIODesignation = 0b00000001 // GPIO1ADC1 This is the alternate function 0 of GPIO1 GPIO1ADC1 GPIODesignation = 0b00000010 // GPIO1LedUartTx This is the alternate function 1 of GPIO1 GPIO1LedUartTx GPIODesignation = 0b00000011 // GPIO1InterruptDetection This is the alternate function 2 of GPIO1 GPIO1InterruptDetection GPIODesignation = 0b00000100 // GPIO2ClockOutput This is the dedicated function of GPIO2 GPIO2ClockOutput GPIODesignation = 0b00000001 // GPIO2ADC2 This is the alternate function 0 of GPIO2 GPIO2ADC2 GPIODesignation = 0b00000010 // GPIO2DAC1 This is the alternate function 1 of GPIO2 GPIO2DAC1 GPIODesignation = 0b00000011 // GPIO3LEDI2C This is the dedicated function of GPIO3 GPIO3LEDI2C GPIODesignation = 0b00000001 // GPIO3ADC3 This is the alternate function 0 of GPIO3 GPIO3ADC3 GPIODesignation = 0b00000010 // GPIO3DAC2 This is the alternate function 1 of GPIO3 GPIO3DAC2 GPIODesignation = 0b00000011 )
type MCP2221 ¶
type MCP2221 struct {
// contains filtered or unexported fields
}
func NewMCP2221 ¶
func NewMCP2221() *MCP2221
func (*MCP2221) GetGPIOParameters ¶ added in v0.3.0
func (d *MCP2221) GetGPIOParameters(ctx context.Context) (MCP2221GPIOParameters, error)
func (*MCP2221) ReadChipSettings ¶ added in v0.6.0
func (*MCP2221) ReadFromAddr ¶
func (*MCP2221) ReadGPIO ¶ added in v0.3.0
func (d *MCP2221) ReadGPIO(ctx context.Context) (MCP2221GPIOValues, error)
func (*MCP2221) ReadGPIOSettings ¶ added in v0.6.0
func (*MCP2221) ReleaseBus ¶
func (d *MCP2221) ReleaseBus(ctx context.Context) (*MCP2221Status, error)
func (*MCP2221) SetGPIOParameters ¶ added in v0.3.0
func (d *MCP2221) SetGPIOParameters(ctx context.Context, params MCP2221GPIOParameters) error
func (*MCP2221) SetVendorAndProductID ¶ added in v0.6.0
func (*MCP2221) UpdateVendorAndProductID ¶ added in v0.6.0
type MCP2221GPIOParameters ¶ added in v0.3.0
type MCP2221GPIOParameters struct { GPIO0Mode GPIOMode `yaml:"GP0_mode"` GPIO0Designation GPIODesignation `yaml:"GP0_designation"` GPIO1Mode GPIOMode `yaml:"GP1_mode"` GPIO1Designation GPIODesignation `yaml:"GP1_designation"` GPIO2Mode GPIOMode `yaml:"GP2_mode"` GPIO2Designation GPIODesignation `yaml:"GP2_designation"` GPIO3Mode GPIOMode `yaml:"GP3_mode"` GPIO3Designation GPIODesignation `yaml:"GP3_designation"` }
type MCP2221GPIOValues ¶ added in v0.3.0
type MCP2221GPIOValues struct { GPIO0Mode GPIOMode `json:"gp0_mode" yaml:"GP0_mode"` GPIO0Value byte `json:"gp0" yaml:"GPIO0"` GPIO1Mode GPIOMode `json:"gp1_mode" yaml:"GP1_mode"` GPIO1Value byte `json:"gp1" yaml:"GPIO1"` GPIO2Mode GPIOMode `json:"gp2_mode" yaml:"GP2_mode"` GPIO2Value byte `json:"gp2" yaml:"GPIO2"` GPIO3Mode GPIOMode `json:"gp3_mode" yaml:"GP3_mode"` GPIO3Value byte `json:"gp3" yaml:"GPIO3"` }
Click to show internal directories.
Click to hide internal directories.