HPI Library

General Description

Describes the HPI master function prototypes.

Functions

cy_hpi_master_status_t Cy_HPI_Master_Init (cy_hpi_master_context_t *context, cy_hpi_master_app_cbk_t *appCbk)
 Initializes the HPI master context members, application callbacks pointer, and initialize the slave devices. More...
 
cy_hpi_master_status_t Cy_HPI_Master_DeInit (cy_hpi_master_context_t *context)
 Deinitializes all the global variables and data structure values. More...
 
cy_hpi_master_status_t Cy_HPI_Master_SlaveDeviceInit (cy_hpi_master_context_t *context, uint8_t slaveAddr, uint8_t intrGpioPort, uint8_t intrGpioPin, uint8_t portCount)
 Configures the HPI slave device information to allow the HPI master to communicate. More...
 
void Cy_HPI_Master_InterruptHandler (cy_hpi_master_context_t *context, uint8_t gpioPort, uint8_t gpioPin)
 Sets the interrupt mask bit and the interrupt is handled by the Cy_HPI_Master_Task function. More...
 
void Cy_HPI_Master_Task (cy_hpi_master_context_t *context)
 Handle the events from the slave devices. More...
 
uint8_t Cy_HPI_Master_GetSlaveIndexByAddr (cy_hpi_master_context_t *context, uint8_t slaveAddr)
 Function return the index of slave devices for the given slave address. More...
 
cy_hpi_master_status_t Cy_HPI_Master_RegisterRead (cy_hpi_master_context_t *context, uint8_t slaveAddr, uint16_t regAddress, uint8_t *readBuff, uint16_t readLen)
 Performs the register read operation using a 16-bit register address. More...
 
cy_hpi_master_status_t Cy_HPI_Master_RegisterWrite (cy_hpi_master_context_t *context, uint8_t slaveAddr, uint16_t regAddress, void *writeBuff, uint16_t writeLen)
 Performs the register write operation using a 16-bit register address. More...
 
cy_hpi_master_status_t Cy_HPI_Master_DevRegRead (cy_hpi_master_context_t *context, uint8_t slaveAddr, uint8_t deviceReg, uint8_t *readBuff, uint16_t readLen)
 Reads data from device-specific registers. More...
 
cy_hpi_master_status_t Cy_HPI_Master_DevRegWrite (cy_hpi_master_context_t *context, uint8_t slaveAddr, uint8_t deviceReg, void *writeBuff, uint16_t writeLen)
 Writes data to the device-specific registers. More...
 
cy_hpi_master_status_t Cy_HPI_Master_FlashMemoryRead (cy_hpi_master_context_t *context, uint8_t slaveAddr, uint8_t *readBuff, uint16_t readLen)
 Reads data from the HPI flash memory region. More...
 
cy_hpi_master_status_t Cy_HPI_Master_FlashMemoryWrite (cy_hpi_master_context_t *context, uint8_t slaveAddr, void *writeBuff, uint16_t writeLen)
 Writes data to the HPI flash memory region. More...
 
cy_hpi_master_status_t Cy_HPI_Master_PortRegRead (cy_hpi_master_context_t *context, uint8_t slaveAddr, uint8_t port, uint8_t portReg, void *readBuff, uint16_t readLen)
 Port register reads the API will be used to read all port-specific registers. More...
 
cy_hpi_master_status_t Cy_HPI_Master_PortRegWrite (cy_hpi_master_context_t *context, uint8_t slaveAddr, uint8_t port, uint8_t portReg, void *writeBuff, uint16_t writeLen)
 Port register write API to all the port-specific registers. More...
 
cy_hpi_master_status_t Cy_HPI_Master_PdResponseRegRead (cy_hpi_master_context_t *context, uint8_t slaveAddr, uint8_t port, uint16_t offset, void *readData, uint16_t readLen)
 PD Response register read API is used for response register read operations. More...
 
cy_hpi_master_status_t Cy_HPI_Master_PdResponseRegWrite (cy_hpi_master_context_t *context, uint8_t slaveAddr, uint8_t port, uint16_t offset, void *writeBuff, uint16_t writeLen)
 PD Response register write API is used for response register write operations. More...
 
bool Cy_HPI_Master_SleepAllowed (cy_hpi_master_context_t *context)
 Checks if the device enters into Deep Sleep mode. More...
 

Function Documentation

◆ Cy_HPI_Master_Init()

cy_hpi_master_status_t Cy_HPI_Master_Init ( cy_hpi_master_context_t context,
cy_hpi_master_app_cbk_t appCbk 
)

Initializes the HPI master context members, application callbacks pointer, and initialize the slave devices.

Call this function before calling any APIs from this library.

Initializes the following structure members in the cy_hpi_master_context_t before calling this function:

  • ptrEventQueue
  • maxSlaveDevices
  • ptrSlaves
  • ptrScbBase
  • ptrI2cContext
  • respBuffLen
  • ptrRespBuff
Parameters
contextHPI master library context pointer.
appCbkRequires application callbacks from the HPI master library.
Returns
CY_HPI_MASTER_SUCCESS - If the operations are successful. CY_HPI_MASTER_FAILURE - If the operations are not successful. CY_HPI_MASTER_INVALID_ARGS - If the input parameter validation failed.

◆ Cy_HPI_Master_DeInit()

cy_hpi_master_status_t Cy_HPI_Master_DeInit ( cy_hpi_master_context_t context)

Deinitializes all the global variables and data structure values.

Parameters
contextHPI master library context pointer.
Returns
CY_HPI_MASTER_SUCCESS - If the operations are successful. CY_HPI_MASTER_INVALID_ARGS - If the input parameter validation failed.

◆ Cy_HPI_Master_SlaveDeviceInit()

cy_hpi_master_status_t Cy_HPI_Master_SlaveDeviceInit ( cy_hpi_master_context_t context,
uint8_t  slaveAddr,
uint8_t  intrGpioPort,
uint8_t  intrGpioPin,
uint8_t  portCount 
)

Configures the HPI slave device information to allow the HPI master to communicate.

Call this function for each slave device on the same I2C bus.

Parameters
contextHPI master library context pointer.
slaveAddrHPI slave device I2C address (7 bits).
intrGpioPortHPI interrupt GPIO port number.
intrGpioPinHPI interrupt GPIO pin number.
portCountNumber of PD ports supported by the slave device.
Returns
CY_HPI_MASTER_SUCCESS - If the operations are successful. CY_HPI_MASTER_FAILURE - If the slave registration failed. CY_HPI_MASTER_INVALID_ARGS - If the input parameter validation failed.

◆ Cy_HPI_Master_InterruptHandler()

void Cy_HPI_Master_InterruptHandler ( cy_hpi_master_context_t context,
uint8_t  gpioPort,
uint8_t  gpioPin 
)

Sets the interrupt mask bit and the interrupt is handled by the Cy_HPI_Master_Task function.

To get the HPI interrupt pin status, call from the GPIO interrupt routine or periodically from the main loop.

Parameters
contextHPI master library context pointer.
gpioPortHPI interrupt GPIO port number.
gpioPinHPI interrupt GPIO pin number.
Returns
None.

◆ Cy_HPI_Master_Task()

void Cy_HPI_Master_Task ( cy_hpi_master_context_t context)

Handle the events from the slave devices.

This function handles the HPI port events from the slave in the interrupt context and the associated data in queue and is called periodically from the main loop of the application firmware.

Parameters
contextHPI master library context pointer.
Returns
None.

◆ Cy_HPI_Master_GetSlaveIndexByAddr()

uint8_t Cy_HPI_Master_GetSlaveIndexByAddr ( cy_hpi_master_context_t context,
uint8_t  slaveAddr 
)

Function return the index of slave devices for the given slave address.

Parameters
contextHPI master library context pointer.
slaveAddrI2C address of the slave device.
Returns
Slave device registered index if found. CY_HPI_MASTER_UNKNOWN_SLAVE_IDX if not found.

◆ Cy_HPI_Master_RegisterRead()

cy_hpi_master_status_t Cy_HPI_Master_RegisterRead ( cy_hpi_master_context_t context,
uint8_t  slaveAddr,
uint16_t  regAddress,
uint8_t *  readBuff,
uint16_t  readLen 
)

Performs the register read operation using a 16-bit register address.

Parameters
contextHPI master library context pointer.
slaveAddrSlave device I2C address (7 bits).
regAddressHPI register address (16 bits).
readBuffReads the data buffer pointer.
readLenRead the number of bytes.
Returns
CY_HPI_MASTER_SUCCESS - If the operation is successful. CY_HPI_MASTER_I2C_FAILURE - If the operation failed. CY_HPI_MASTER_INVALID_ARGS - Invalid arguments passed.

◆ Cy_HPI_Master_RegisterWrite()

cy_hpi_master_status_t Cy_HPI_Master_RegisterWrite ( cy_hpi_master_context_t context,
uint8_t  slaveAddr,
uint16_t  regAddress,
void *  writeBuff,
uint16_t  writeLen 
)

Performs the register write operation using a 16-bit register address.

Parameters
contextPointer of the HPI master context structure.
slaveAddrI2C address (7 bits) of the slave device.
regAddressHPI register address (16 bits).
writeBuffWrites the data buffer pointer.
writeLenWrite the number of bytes.
Returns
CY_HPI_MASTER_SUCCESS - If the operation is successful. CY_HPI_MASTER_I2C_FAILURE - If the operation failed. CY_HPI_MASTER_INVALID_ARGS - Invalid arguments passed.

◆ Cy_HPI_Master_DevRegRead()

cy_hpi_master_status_t Cy_HPI_Master_DevRegRead ( cy_hpi_master_context_t context,
uint8_t  slaveAddr,
uint8_t  deviceReg,
uint8_t *  readBuff,
uint16_t  readLen 
)

Reads data from device-specific registers.

Parameters
contextHPI master library context pointer.
slaveAddrSlave device I2C address (7 bits).
deviceRegHPI device-specific register address.
readBuffReads the data buffer pointer.
readLenRead the number of bytes.
Returns
CY_HPI_MASTER_SUCCESS - If the operation is successful. CY_HPI_MASTER_I2C_FAILURE - If the operation failed. CY_HPI_MASTER_INVALID_ARGS - Invalid arguments passed.

◆ Cy_HPI_Master_DevRegWrite()

cy_hpi_master_status_t Cy_HPI_Master_DevRegWrite ( cy_hpi_master_context_t context,
uint8_t  slaveAddr,
uint8_t  deviceReg,
void *  writeBuff,
uint16_t  writeLen 
)

Writes data to the device-specific registers.

Parameters
contextPointer of the HPI master context structure.
slaveAddrI2C address (7 bits) of the slave device.
deviceRegHPI device-specific register address.
writeBuffWrites the data buffer pointer.
writeLenWrite the number of bytes.
Returns
CY_HPI_MASTER_SUCCESS - If the operation is successful. CY_HPI_MASTER_I2C_FAILURE - If the operation failed. CY_HPI_MASTER_INVALID_ARGS - Invalid arguments passed.

◆ Cy_HPI_Master_FlashMemoryRead()

cy_hpi_master_status_t Cy_HPI_Master_FlashMemoryRead ( cy_hpi_master_context_t context,
uint8_t  slaveAddr,
uint8_t *  readBuff,
uint16_t  readLen 
)

Reads data from the HPI flash memory region.

Parameters
contextHPI master library context pointer.
slaveAddrSlave device I2C address (7 bits).
readBuffRead the data buffer pointer.
readLenRead the number of bytes.
Returns
CY_HPI_MASTER_SUCCESS - If the operation is successful. CY_HPI_MASTER_I2C_FAILURE - If the operation failed. CY_HPI_MASTER_INVALID_ARGS - Invalid arguments passed.

◆ Cy_HPI_Master_FlashMemoryWrite()

cy_hpi_master_status_t Cy_HPI_Master_FlashMemoryWrite ( cy_hpi_master_context_t context,
uint8_t  slaveAddr,
void *  writeBuff,
uint16_t  writeLen 
)

Writes data to the HPI flash memory region.

Parameters
contextHPI master library context pointer.
slaveAddrSlave device I2C address (7 bits).
writeBuffWrite the data buffer pointer.
writeLenWrites the number of bytes.
Returns
CY_HPI_MASTER_SUCCESS - If the operation is successful. CY_HPI_MASTER_I2C_FAILURE - If the operation failed. CY_HPI_MASTER_INVALID_ARGS - Invalid arguments passed.

◆ Cy_HPI_Master_PortRegRead()

cy_hpi_master_status_t Cy_HPI_Master_PortRegRead ( cy_hpi_master_context_t context,
uint8_t  slaveAddr,
uint8_t  port,
uint8_t  portReg,
void *  readBuff,
uint16_t  readLen 
)

Port register reads the API will be used to read all port-specific registers.

Parameters
contextHPI master library context pointer.
slaveAddrSlave device I2C address (7 bits).
portReads the slave port number associated with the register.
portRegPort register address.
readBuffReads the data buffer pointer.
readLenRead the number of bytes.
Returns
CY_HPI_MASTER_SUCCESS - If the operation is successful. CY_HPI_MASTER_I2C_FAILURE - If the operation failed. CY_HPI_MASTER_INVALID_ARGS - Invalid arguments passed.

◆ Cy_HPI_Master_PortRegWrite()

cy_hpi_master_status_t Cy_HPI_Master_PortRegWrite ( cy_hpi_master_context_t context,
uint8_t  slaveAddr,
uint8_t  port,
uint8_t  portReg,
void *  writeBuff,
uint16_t  writeLen 
)

Port register write API to all the port-specific registers.

Parameters
contextHPI master library context pointer.
slaveAddrSlave device I2C address (7 bits).
portWrites the Slave port number associated with the register.
portRegPort register address.
writeBuffWrites the data buffer pointer.
writeLenWrite the number of bytes.
Returns
CY_HPI_MASTER_SUCCESS - If the operation is successful. CY_HPI_MASTER_I2C_FAILURE - If the operation failed. CY_HPI_MASTER_INVALID_ARGS - Invalid arguments passed.

◆ Cy_HPI_Master_PdResponseRegRead()

cy_hpi_master_status_t Cy_HPI_Master_PdResponseRegRead ( cy_hpi_master_context_t context,
uint8_t  slaveAddr,
uint8_t  port,
uint16_t  offset,
void *  readData,
uint16_t  readLen 
)

PD Response register read API is used for response register read operations.

Parameters
contextHPI master library context pointer.
slaveAddrSlave device I2C address (7 bits).
portSlave device port number.
offsetOffset from the response register base address.
readDataReads the data buffer pointer.
readLenRead the number of bytes.
Returns
CY_HPI_MASTER_SUCCESS - If the operation is successful. CY_HPI_MASTER_I2C_FAILURE - If the operation failed. CY_HPI_MASTER_INVALID_ARGS - Invalid arguments passed.

◆ Cy_HPI_Master_PdResponseRegWrite()

cy_hpi_master_status_t Cy_HPI_Master_PdResponseRegWrite ( cy_hpi_master_context_t context,
uint8_t  slaveAddr,
uint8_t  port,
uint16_t  offset,
void *  writeBuff,
uint16_t  writeLen 
)

PD Response register write API is used for response register write operations.

Parameters
contextHPI master library context pointer.
slaveAddrSlave device I2C address (7 bits).
portSlave device port number.
offsetOffset from the response register base address.
writeBuffWrites the data buffer pointer.
writeLenWrite the number of bytes.
Returns
CY_HPI_MASTER_SUCCESS - If the operation is successful. CY_HPI_MASTER_I2C_FAILURE - If the operation failed. CY_HPI_MASTER_INVALID_ARGS - Invalid arguments passed.

◆ Cy_HPI_Master_SleepAllowed()

bool Cy_HPI_Master_SleepAllowed ( cy_hpi_master_context_t context)

Checks if the device enters into Deep Sleep mode.

Parameters
contextHPI master library context pointer.
Returns
true - If switches into Deep Sleep mode. false - If the operation failed.