| spips Vitis Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Functions
xspips_tpm_polled_example.c File Reference

## Overview

This file contains a design example using the SPI driver (XSpiPs) in polled mode and hardware device with a Trusted Platform Module device.

This example sends TPM commands to device based on user inputs and displays the response.

Note

None.

     MODIFICATION HISTORY:

     Ver   Who  Date     Changes

     1.00  sg  04/02/21 Initial release
     3.9   sb  07/05/23 Added support for system device-tree flow.

## Functions
int | SpiPsReadID (XSpiPs *SpiPtr)
| This function reads vendor identification information. More...
int | SpiPsTpmStatusGet (XSpiPs *SpiPtr, u8 *StatusPtr)
| This function gets TPM status. More...
int | SpiPsTpmStatusSet (XSpiPs *SpiPtr, u8 StatusVal)
| This function sets the TPM status. More...
int | SpiPsTpmAccessGet (XSpiPs *SpiPtr, u8 *AccessPtr)
| This function gets TPM access configuration. More...
int | SpiPsTpmAccessSet (XSpiPs *SpiPtr, u8 Access)
| This function sets TPM access configuration. More...
int | SpiPsTpmFifoRead (XSpiPs *SpiPtr, u8 *DataPtr, u8 ByteCount)
| This function reads data from TPM FIFO. More...
int | SpiPsTpmFifoWrite (XSpiPs *SpiPtr, u8 *DataPtr, u8 ByteCount)
| This function write the data TPM FIFO. More...
int | SpiPsTpmTransfer (XSpiPs *SpiPtr, u32 Address, u8 *TxBuf, u8 *RxBuf, u16 Length)
| This function sets TPM access configuration. More...
int | SpiPsTpmDataTransfer (XSpiPs *SpiPtr, u8 *TxBuf, u8 *RxBuf, u16 Txlen)
| This function sets TPM access configuration. More...
int | SpiPsTpmPolledExample (XSpiPs *SpiInstancePtr, u16 SpiDeviceId)
int | main (void)
| Main function to call the Spi TPM example. More...

## Function Documentation

int main | ( | void |  | ) |

Main function to call the Spi TPM example.

Parameters

  None |

Returns
  XST_SUCCESS if successful, otherwise XST_FAILURE.

Note
  None

References SpiPsTpmPolledExample().

int SpiPsReadID | ( | XSpiPs * | SpiPtr | ) |

This function reads vendor identification information.

Parameters

  SpiPtr | is a pointer to the SPIPS driver component to use.

Returns
  XST_SUCCESS if successful, else XST_FAILURE.

Note
  None.

References SpiPsTpmTransfer().

Referenced by SpiPsTpmPolledExample().

int SpiPsTpmAccessGet | ( | XSpiPs * | SpiPtr,
|  | u8 * | AccessPtr
| ) |  |

This function gets TPM access configuration.

Parameters

  SpiPtr | is a pointer to the SPIPS driver component to use.
  AccessPtr | is pointer to get access configuration

Returns
  XST_SUCCESS if successful, else XST_FAILURE.

Note
  None.

References SpiPsTpmTransfer().

Referenced by SpiPsTpmPolledExample().

int SpiPsTpmAccessSet | ( | XSpiPs * | SpiPtr,
|  | u8 | Access
| ) |  |

This function sets TPM access configuration.

Parameters

  SpiPtr | is a pointer to the SPIPS driver component to use.
  Access | is set access configuration value

Returns
  XST_SUCCESS if successful, else XST_FAILURE.

Note
  None.

References SpiPsTpmTransfer().

Referenced by SpiPsTpmPolledExample().

int SpiPsTpmDataTransfer | ( | XSpiPs * | SpiPtr,
|  | u8 * | TxBuf,
|  | u8 * | RxBuf,
|  | u16 | Txlen
| ) |  |

This function sets TPM access configuration.

Parameters

  SpiPtr | is a pointer to the SPIPS driver component to use.
  TxBuf | is pointer to transmit buffer
  RxBuf | is pointer to receive buffer
  Txlen | is data transfer length

Returns
  XST_SUCCESS if successful, else XST_FAILURE.

Note
  None.

References SpiPsTpmFifoRead(), SpiPsTpmFifoWrite(), SpiPsTpmStatusGet(), and SpiPsTpmStatusSet().

Referenced by SpiPsTpmPolledExample().

int SpiPsTpmFifoRead | ( | XSpiPs * | SpiPtr,
|  | u8 * | DataPtr,
|  | u8 | ByteCount
| ) |  |

This function reads data from TPM FIFO.

Parameters

  SpiPtr | is a pointer to the SPIPS driver component to use.
  Data | is to be read to data FIFO
  ByteCount | is the number of bytes to read.

Returns
  XST_SUCCESS if successful, else XST_FAILURE.

Note
  None.

References SpiPsTpmTransfer().

Referenced by SpiPsTpmDataTransfer().

int SpiPsTpmFifoWrite | ( | XSpiPs * | SpiPtr,
|  | u8 * | DataPtr,
|  | u8 | ByteCount
| ) |  |

This function write the data TPM FIFO.

Parameters

  SpiPtr | is a pointer to the SPIPS driver component to use.
  DataPtr | is data pointer to be written to FIFO.
  ByteCount | is the number of bytes to read.

Returns
  XST_SUCCESS if successful, else XST_FAILURE.

Note
  None.

References SpiPsTpmTransfer().

Referenced by SpiPsTpmDataTransfer().

int SpiPsTpmPolledExample | ( | XSpiPs * | SpiInstancePtr,
|  | u16 | SpiDeviceId
| ) |  |

Parameters

  SpiInstancePtr | is a pointer to the Spi Instance.
  SpiDeviceId | is the Device Id of Spi.

Returns
  XST_SUCCESS if successful else XST_FAILURE.

Note

References XSpiPs_Config::BaseAddress, SpiPsReadID(), SpiPsTpmAccessGet(), SpiPsTpmAccessSet(), SpiPsTpmDataTransfer(), XSpiPs_CfgInitialize(), XSPIPS_CLK_PRESCALE_16, XSPIPS_FORCE_SSELECT_OPTION, XSpiPs_LookupConfig(), XSPIPS_MANUAL_START_OPTION, XSPIPS_MASTER_OPTION, XSpiPs_SelfTest(), XSpiPs_SetClkPrescaler(), XSpiPs_SetOptions(), and XSpiPs_SetSlaveSelect().

Referenced by main().

int SpiPsTpmStatusGet | ( | XSpiPs * | SpiPtr,
|  | u8 * | StatusPtr
| ) |  |

This function gets TPM status.

Parameters

  SpiPtr | is a pointer to the SPIPS driver component to use.
  StatusPtr | is pointer to read status

Returns
  XST_SUCCESS if successful, else XST_FAILURE.

Note
  None.

References SpiPsTpmTransfer().

Referenced by SpiPsTpmDataTransfer().

int SpiPsTpmStatusSet | ( | XSpiPs * | SpiPtr,
|  | u8 | StatusVal
| ) |  |

This function sets the TPM status.

Parameters

  SpiPtr | is a pointer to the SPIPS driver component to use.
  StatusVal | is to be written to status register

Returns
  XST_SUCCESS if successful, else XST_FAILURE.

Note
  None.

References SpiPsTpmTransfer().

Referenced by SpiPsTpmDataTransfer().

int SpiPsTpmTransfer | ( | XSpiPs * | SpiPtr,
|  | u32 | Address,
|  | u8 * | TxBuf,
|  | u8 * | RxBuf,
|  | u16 | Length
| ) |  |

This function sets TPM access configuration.

Parameters

  SpiPtr | is a pointer to the SPIPS driver component to use.
  Address | register address
  TxBuf | is pointer to transmit buffer
  RxBuf | is pointer to receive buffer
  Length | is transfer length

Returns
  XST_SUCCESS if successful, else XST_FAILURE.

Note
  None.

References XSpiPs_PolledTransfer().

Referenced by SpiPsReadID(), SpiPsTpmAccessGet(), SpiPsTpmAccessSet(), SpiPsTpmFifoRead(), SpiPsTpmFifoWrite(), SpiPsTpmStatusGet(), and SpiPsTpmStatusSet().