Skip to content

A pure Julia implementation of a driver for the MCP2221 chip (USB 2.0 to I2C/UART Protocol Converter with GPIO)

License

Notifications You must be signed in to change notification settings

Klafyvel/MCP2221Driver.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP2221Driver

Stable Dev Build Status Aqua

MCP2221Driver.jl is a driver to use Microship's MCP2221 hardware through HidApi. This enables I²C communications, GPIO operations, and analog IO operations directly from Julia using this hardware. For now, only the low-level API is available.

Installation

The package can be installed throug the package manager:

]add MCP2221Driver

Example

See the tutorial for more in-depth usage examples. Here is an example blink program:

using MCP2221Driver
import HidApi
HidApi.init()

device = open(HidApi.find_device(
    MCP2221Driver.MCP2221A_DEFAULT_VID, 
    MCP2221Driver.MCP2221A_DEFAULT_PID
))

# Configuring pins for GPIO operations
command = MCP2221Driver.GetSRAMSettingsCommand()
response = MCP2221Driver.query(device, command)
command = MCP2221Driver.SetSRAMSettingsCommand(
    gpiosettings=(
        gpio0=response.gpio0status, 
        gpio1=response.gpio1status, 
        gpio2=MCP2221Driver.GPIOStatus(false, 
                                       MCP2221Driver.GPIOOutput, 
                                       MCP2221Driver.GPIOOperation
                                       ), 
        gpio3=MCP2221Driver.GPIOStatus(false, 
                                       MCP2221Driver.GPIOOutput, 
                                       MCP2221Driver.GPIOOperation
                                       )
    )
)
MCP2221Driver.query(device, command)

# Actual blinking
for i in 1:60
    command = MCP2221Driver.SetGPIOOutputValuesCommand(gp2outputvalue=isodd(i), gp3outputvalue=iseven(i))
    MCP2221Driver.query(device, command)
    sleep(1)
end

close(device)
HidApi.shutdown()

About

A pure Julia implementation of a driver for the MCP2221 chip (USB 2.0 to I2C/UART Protocol Converter with GPIO)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy