|
MCP2210 Library
An Open Source MCP2210 Library for Linux.
|
#include "mcp2210.h"| ChipStatusDef CancelSPITransfer | ( | hid_device * | handle | ) |
Cancel the current SPI transfer
| handle | The handle to the MCP2210 device |
Enumerate the connected MCP2210's
| ChipSettingsDef GetChipSettings | ( | hid_device * | handle, |
| bool | isVolatile = true |
||
| ) |
Get power-up settings
| handle | The handle to the MCP2210 device |
| isVolatile | (default true) Whether to make change permanently or in memory only. |
| ChipStatusDef GetChipStatus | ( | hid_device * | handle | ) |
Get MCP2210 status
| handle | The handle to the MCP2210 device |
| GPPinDef GetGPIOPinDirection | ( | hid_device * | handle | ) |
Get GPIO current pin direction from volatile memory
| handle | The handle to the MCP2210 device |
| GPPinDef GetGPIOPinValue | ( | hid_device * | handle | ) |
Get GPIO current pin value
| handle | The handle to the MCP2210 device |
| ManufacturerProductNameDef GetManufacturerProductName | ( | hid_device * | handle, |
| unsigned int | subCmdCode | ||
| ) |
Set USB manufacturer name or product name
| handle | The handle to the MCP2210 device |
| subCmdCode | The sub command code which determines whether the action is to set manufacturer name or product name: |
CMDSUB_USB_MANUFACTURER_NAME: set manufacturer name CMDSUB_USB_PRODUCT_NAME: set product name
| ExternalInterruptPinStatusDef GetNumOfEventsFromInterruptPin | ( | hid_device * | handle, |
| byte | resetCounter | ||
| ) |
Get the current number of events from the interrupt pin
Note, GP6 must be configured to have its dedicated function active.
| handle | The handle to the MCP2210 device |
| resetCounter | 0x0: reads, then resets the event counter >0: the event counter is read, however the counter is not reset |
| SPITransferSettingsDef GetSPITransferSettings | ( | hid_device * | handle, |
| bool | isVolatile = true |
||
| ) |
Get SPI power-up transfer settings
| handle | The handle to the MCP2210 device |
| isVolatile | (default true) Whether to make change permanently or in memory only. |
ture: in memory only. false: changes are written to NVRAM
| USBKeyParametersDef GetUSBKeyParameters | ( | hid_device * | handle | ) |
Get USB power-up key parameters
| handle | The handle to the MCP2210 device |
| hid_device* InitMCP2210 | ( | unsigned short | vid, |
| unsigned short | pid, | ||
| wchar_t * | serialNumber | ||
| ) |
Initialize MCP2210 (using all parameters)
| vid | Vender ID |
| pid | Product ID |
| serialNumber | Serial number |
| hid_device* InitMCP2210 | ( | wchar_t * | serialNumber | ) |
Initialize MCP2210 (if more than one is present) Vendor ID: 0x04d8 Product ID: 0x00de
| serialNumber | The serial number of the MCP2210 device |
| hid_device* InitMCP2210 | ( | ) |
Initialize MCP2210 Vendor ID: 0x04d8 Product ID: 0x00de
| int ReadEEPROM | ( | hid_device * | handle, |
| byte | addr, | ||
| byte * | val | ||
| ) |
Read EEPROM Memory
| handle | The handle to the MCP2210 device |
| addr | The address to be accessed (0-255) |
| val | The byte read at the specified address |
| void ReleaseMCP2210 | ( | hid_device * | handle | ) |
Release the device handle and close the device
| handle | The handle to the MCP2210 device |
| int RequestSPIBusRelease | ( | hid_device * | handle, |
| byte | val | ||
| ) |
Request SPI bus release
| handle | The handle to the MCP2210 device |
| val | The value of the SPI bus release ACK pin (only if GP7 is assigned to this dedicated function) |
| int SendAccessPassword | ( | hid_device * | handle, |
| char * | pwd, | ||
| int | pwdLength | ||
| ) |
Send access password
| handle | The handle to the MCP2210 device |
| pwd | password |
| pwdLength | password length (<=8) |
| int SendUSBCmd | ( | hid_device * | handle, |
| byte * | cmdBuf, | ||
| byte * | responseBuf | ||
| ) |
Send a USB command
| handle | The handle to the MCP2210 device |
| cmdBuf | command buffer (64 bytes), unused/reserved entries must be filled with zero. |
| responseBuf | the buffer (64 bytes) that contains the response. |
| int SetChipSettings | ( | hid_device * | handle, |
| ChipSettingsDef | def, | ||
| bool | isVolatile = true |
||
| ) |
Set chip settings power-up default
| handle | The handle to the MCP2210 device |
| def |
| isVolatile | (default true) Whether to make change permanently or in memory only. |
ture: in memory only. false: changes are written to NVRAM
| int SetGPIOPinDirection | ( | hid_device * | handle, |
| GPPinDef | def | ||
| ) |
Set GPIO current pin direction in volatile memory
| handle | The handle to the MCP2210 device |
| def |
| int SetGPIOPinVal | ( | hid_device * | handle, |
| GPPinDef | def | ||
| ) |
Set GPIO current pin value
| handle | The handle to the MCP2210 device |
| def |
| int SetManufacturerProductName | ( | hid_device * | handle, |
| unsigned int | subCmdCode, | ||
| ManufacturerProductNameDef | def | ||
| ) |
Set USB manufacturer name or product name
| handle | The handle to the MCP2210 device |
| subCmdCode | The sub command code which determines whether the action is to set manufacturer name or product name: |
CMDSUB_USB_MANUFACTURER_NAME: set manufacturer name CMDSUB_USB_PRODUCT_NAME: set product name
| def |
| int SetSPITransferSettings | ( | hid_device * | handle, |
| SPITransferSettingsDef | def, | ||
| bool | isVolatile = true |
||
| ) |
Set SPI power-up transfer settings
| handle | The handle to the MCP2210 device |
| def |
| isVolatile | (default true) Whether to make change permanently or in memory only. |
ture: in memory only. false: changes are written to NVRAM
| int SetUSBKeyParameters | ( | hid_device * | handle, |
| USBKeyParametersDef | def | ||
| ) |
Set USB power-up key parameters
| handle | The handle to the MCP2210 device |
| def |
| SPIDataTransferStatusDef SPIDataTransfer | ( | hid_device * | handle, |
| byte * | data, | ||
| int | length | ||
| ) |
SPI Data Transfer
| handle | The handle to the MCP2210 device |
| data | a pointer to the data array to be transfered |
| length | number of bytes to be transfered |
| SPIDataTransferStatusDef SPISendReceive | ( | hid_device * | handle, |
| byte * | data, | ||
| int | cmdBufferLength, | ||
| int | dataLength = -1 |
||
| ) |
Send data and wait till results are received from the SPI bus.
Note: this method differers from SPIDataTransfer in that it also waits till the transfer is finished. In SPIDataTransfer, the SPIEngineStatus in the returned data structure tells the status of the SPI engine, and the call returns after the data is sent, regardless of whether the data has been received.
| handle | The handle to the MCP2210 device |
| data | a pointer to the data array to be transfered |
| cmdBufferLength | number of command bytes to be transfered |
| dataLength | (optional) number of data elements to be returned |
if this parameter is not supplied the default length is set to be the same as the command buffer length
| int WriteEEPROM | ( | hid_device * | handle, |
| byte | addr, | ||
| byte | val | ||
| ) |
Write EEPROM Memory
| handle | The handle to the MCP2210 device |
| addr | The address to be accessed (0-255) |
| val | The byte to be written to the specified address. |