Code Examples - HPE Edgeline EL300 Getting Started Manual

Converged edge system daughter card
Table of Contents

Advertisement

4. Reset the multiplexer by changing the signal back to high on GP0 of the Microchip chip.
5. Write the byte from above to the control register of the main chip.
NOTE: Any changes to the Mode on this web page MUST be accompanied by changing the
configuration byte of the main chip. Failure to do so will end up in unexpected results.
Failing to reset the multiplexer will cause the iSM web page to be unable to display the correct
information.

Code Examples

While there are several programming languages that can interact with the DIO, the C language is used in
these examples. While these examples work, they are designed to display how the interaction works and
are not necessarily complete.
In these example, the slave address of the I2C bus is set as 0x21. This is a fixed value, which should be
used in all communication.
C Language
MicroChip has supplied a library for communicating through the I2C protocol to the DIO. This library can
be located and downloaded from the Microchip website. After downloading and installing the library, the
following API calls are used:
Mcp2221_GetConnectedDevices - retrieves a list of connected devices
Mcp2221_OpenByIndex - opens a device by an index number
Mcp2221_SmbusReadByte - sends the Smb read byte command
Mcp2221_SmbusWriteByte - sends the Smb write byte command
These commands are used to communicate with the four registers described above. As always, each
return code should be inspected and errors should be dealt with accordingly. Error code definitions are
listed in the documentation installed with the Microchip MCP2221 library.
To use the Microchip library, the vendor and device ids are required. According to Microchip's
documentation, the vendor ID is 0x04d8 and the device ID is 0x00dd. Both these IDs are required to
access the I2C bus.
Open the device
Open the device and establish a handle to allow the application to interact with the device directly.
List the connected devices
const int vendorID = 0x04D8;
const int productID = 0x00DD;
//get the number of connected devices
unsigned int connectedDevices = 0;
rc = Mcp2221_GetConnectedDevices(0x04D8, productID, &connectedDevices);
Open the device by index
void *handle = Mcp2221_OpenByIndex(vendorID, productID, 0)
open
Close the device
22
8 Bit Configurable GPIO Daughter Card (with 12 pin Phoenix Connector)
//index of the connected device to

Advertisement

Table of Contents
loading

Table of Contents