The Host Processor Interface (HPI) master library implements a set of APIs through which the application communicates over the HPI interface to monitor or control the operating condition of other HPI slave devices.
The middleware implements an asynchronous interrupt-based event queue handling.
HPI master communicates over an I2C interface (supported clock frequencies are 1 MHz, 400 kHz, and 100 kHz) with an interrupt line using a GPIO.
Features:
- Firmware version identification
- Firmware update capability
- Enquiry of Type-C and USB PD connection status
- Control of USB PD power profiles
General description
Includes cy_hpi_master_defines.h and cy_hpi_master.h to access all the functions and other declarations in this library. See the Quick Start Guide to use the HPI library.
See the Supported software and tools section for compatibility information.
See the Changelog section for change history.
Quick Start Guide
HPI master middleware is used in ModusToolbox(TM) based development environment. See the Supported software and tools section.
These steps describe the simplest method to enable the HPI master middleware in an application.
- Create or open an application to add HPI master functions.
- Add the HPI master middleware to your project. This quick start guide assumes that the environment is configured to use the MTB CAT2 Peripheral Driver Library (PDL) for development and the PDL is included in the project.
- Include cy_hpi_master.h and cy_hpi_master_defines.h to get access to all functions and other declarations in this library.
#include "cy_hpi_master.h"
#include "cy_hpi_master_defines.h"
- Define the following data structures required by the HPI master middleware:
- HPI master required buffers and data structures
static cy_stc_scb_i2c_context_t gl_hpimI2cContext;
static uint8_t gl_hpimResponseBuffer[0x40U];
static uint8_t gl_hpimEvtQueueBuffer[0x200U];
{
.bufferSize = 0x200U,
.headIdx = 0x00U,
.tailIdx = 0x00U
};
- HPI master context parameters
{
.maxSlaveDevices = 0x03U,
.ptrSlaves = gl_hpimSlaveDevices,
.ptrScbBase = SCB0,
.ptrI2cContext = &gl_hpimI2cContext,
.respBuffLen = 0x40U,
.ptrRespBuff = gl_hpimResponseBuffer,
};
- Register application callback functions
{
.i2c_master_write = i2c_master_write,
.event_handler = hpi_master_event_handler,
.error_handler = hpi_master_error_handler
};
The HPI master library uses these callbacks registered by the application to perform the application-specific tasks such as read/write on the I2C bus, handle slave events, handle error conditions, and so on.
- Initialize the HPI master middleware. Configure and initialize the I2C SCB before calling this function.
Register a slave device. The interrupt GPIO is already configured.
- Invoke the Cy_HPI_Master_InterruptHandler function from the GPIO interrupt service routine for each slave device.
- Call Cy_HPI_Master_Task from the main processing loop of the application to handle the slave device events.
Configuration considerations
Limitations and restrictions
|
| Macros |
| Describes the HPI master macros.
|
|
| Functions |
| Describes the HPI master function prototypes.
|
|
| Data Structures |
| Describes the data structures defined by the HPI master.
|
|
| Enumerated types |
| Describes the enumeration types defined by the HPI master.
|
|