HPI Library
HPIM (HPI Master)

General Description

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:

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.

  1. Create or open an application to add HPI master functions.
  2. 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.
  3. 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"
  4. 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; /* I2C master context */
      static uint8_t gl_hpimResponseBuffer[0x40U]; /* Buffer to handle slave response messages */
      static cy_hpi_master_slave_dev_t gl_hpimSlaveDevices[0x03U]; /* HPI slave devices */
      static uint8_t gl_hpimEvtQueueBuffer[0x200U]; /* Buffer to handle event queue */
      static cy_hpi_master_event_queue_t gl_hpimEventQueue = /* Event Queue */
      {
      .startAddress = gl_hpimEvtQueueBuffer, /* Queue Buffer */
      .bufferSize = 0x200U, /* Buffer Size in bytes */
      .headIdx = 0x00U, /* Queue head index */
      .tailIdx = 0x00U /* Queue tail index */
      };
    • HPI master context parameters
      static cy_hpi_master_context_t gl_hpimContext =
      {
      .ptrEventQueue = &gl_hpimEventQueue, /* Event Queue */
      .maxSlaveDevices = 0x03U, /* Supported slave devices max count*/
      .ptrSlaves = gl_hpimSlaveDevices, /* Pointer to slave device array*/
      .ptrScbBase = SCB0, /* I2C SCB base address */
      .ptrI2cContext = &gl_hpimI2cContext, /* I2C context */
      .respBuffLen = 0x40U, /* Response buffer length in bytes */
      .ptrRespBuff = gl_hpimResponseBuffer, /* Pointer to response buffer */
      };
    • Register application callback functions
      static cy_hpi_master_app_cbk_t gl_hpimAppCallback =
      {
      .i2c_master_read = i2c_master_read,
      .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.
  5. Initialize the HPI master middleware. Configure and initialize the I2C SCB before calling this function.
    (void)Cy_HPI_Master_Init(&gl_hpimContext, &gl_hpimAppCallback);
  6. Register a slave device. The interrupt GPIO is already configured.

    (void)Cy_HPI_Master_SlaveDeviceInit(&gl_hpimContext, /* Pointer to HPI master context */
    0x08, /* Slave address (7-bit) */
    2, /* Interrupt GPIO port number */
    1, /* Interrupt GPIO pin number */
    2); /* Supported port count */
  7. Invoke the Cy_HPI_Master_InterruptHandler function from the GPIO interrupt service routine for each slave device.
    (void)Cy_HPI_Master_InterruptHandler(&gl_hpimContext, /* Pointer to HPI master context */
    2, /* Interrupt GPIO port number */
    1); /* Interrupt GPIO pin number */
  8. Call Cy_HPI_Master_Task from the main processing loop of the application to handle the slave device events.
    (void)Cy_HPI_Master_Task(&gl_hpimContext);

Configuration considerations

Limitations and restrictions

API Reference

 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.