PSOC E8XXGP Device Support Library

| PSOC E8XXGP Device Support Library

Functions
Functions
PDL API Reference » RRAM (Resistive Random Access Memory)

## General Description

Note
  In order to acquire PC_LOCK from CM33 the bootrow(0x50100000) value should be updated with 0xdb, 0x00, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 where 0xdb should be written at 0th offset. Bootrow can be updated using Cy_RRAM_OtpReadByteArray() API.

## Functions
cy_en_rram_status_t | Cy_RRAM_OtpWriteByteArray (RRAMC_Type *base, uint32_t addr, const uint8_t *data, uint32_t numBytes)
| Writes array of byte data to the specified address. More...
cy_en_rram_status_t | Cy_RRAM_OtpReadByteArray (RRAMC_Type *base, uint32_t addr, uint8_t *data, uint32_t numBytes)
| Reads array of byte data from the specified address. More...
cy_en_rram_status_t | Cy_RRAM_OtpWriteWord (RRAMC_Type *base, uint32_t addr, uint32_t data)
| Writes a 32-bit word data to the specified address. More...
cy_en_rram_status_t | Cy_RRAM_OtpReadWord (RRAMC_Type *base, uint32_t addr, uint32_t *data)
| Reads a 32bit word data from the specified address. More...
cy_en_rram_status_t | Cy_RRAM_OtpWriteBlock (RRAMC_Type *base, uint32_t addr, uint8_t *data)
| Writes a block(16B) data to the specified address. More...
cy_en_rram_status_t | Cy_RRAM_NvmWriteByteArray (RRAMC_Type *base, uint32_t addr, const uint8_t *data, uint32_t numBytes)
| Writes array of byte data to the specified address in blocking mode. More...
cy_en_rram_status_t | Cy_RRAM_NvmReadByteArray (RRAMC_Type *base, uint32_t addr, uint8_t *data, uint32_t numBytes)
| Reads array of byte data from the specified address. More...
cy_en_rram_status_t | Cy_RRAM_NonBlockingNvmWriteByteArray (RRAMC_Type *base, uint32_t addr, const uint8_t *data, uint32_t numBytes)
| Writes array of byte data to the specified address in Non Blocking mode. More...
cy_en_rram_status_t | Cy_RRAM_NvmWriteBlock (RRAMC_Type *base, uint32_t addr, uint8_t *data)
| Writes a block(16B) data to the specified address. More...
cy_en_rram_status_t | Cy_RRAM_WriteByteArray (RRAMC_Type *base, uint32_t addr, const uint8_t *data, uint32_t numBytes)
| Writes array of byte data to the specified address in blocking mode. More...
cy_en_rram_status_t | Cy_RRAM_TSWriteByteArray (RRAMC_Type *base, uint32_t addr, const uint8_t *data, uint32_t numBytes)
| Writes an array of byte data to the specified address in blocking mode without considering uncorrectable ECC fail error. More...
cy_en_rram_status_t | Cy_RRAM_ReadByteArray (RRAMC_Type *base, uint32_t addr, uint8_t *data, uint32_t numBytes)
| Reads an array of byte data from the specified address. More...
cy_en_rram_status_t | Cy_RRAM_TSReadByteArray (RRAMC_Type *base, uint32_t addr, uint8_t *data, uint32_t numBytes)
| Reads an array of byte data from the specified address after validating the uncorrectable ECC fail bits. More...
cy_en_rram_status_t | Cy_RRAM_Init (RRAMC_Type *base, cy_en_rram_vmode_t vmode, bool retrvAlgoInfo)
| Retrieves configuration settings from configuration space in extra area. More...
__STATIC_INLINE uint32_t | Cy_RRAM_GetStatus (RRAMC_Type *base)
| Get the status of RRAM. More...
__STATIC_INLINE bool | Cy_RRAM_IsBusy (RRAMC_Type *base)
| Indicates the status of NVM Busy flag. More...
__STATIC_INLINE cy_en_rram_hresp_t | Cy_RRAM_GetAHBError (RRAMC_Type *base)
| Gets AHB bus error occurred during transactions. More...
__STATIC_INLINE void | Cy_RRAM_EnableSleepMode (RRAMC_Type *base)
| Puts RRAM in Sleep mode. More...
__STATIC_INLINE void | Cy_RRAM_DisableSleepMode (RRAMC_Type *base)
| Puts RRAM in Normal mode. More...
__STATIC_INLINE cy_en_rram_sleep_t | Cy_RRAM_GetSleepStatus (RRAMC_Type *base)
| Gets the sleep status of RRAM. More...
cy_en_rram_status_t | Cy_RRAM_EnableWP (RRAMC_Type *base, uint32_t numSectors)
| Enables write protection for number of sectors starting with sector 0 in RRAM NVM region. More...
cy_en_rram_status_t | Cy_RRAM_DisableWP (RRAMC_Type *base)
| Disables write protection for all sectors in RRAM NVM region. More...
__STATIC_INLINE void | Cy_RRAM_SetWPLock (RRAMC_Type *base)
| Enables the write protection lock by setting WPLCK to 1. More...
__STATIC_INLINE cy_en_rram_wp_lock_t | Cy_RRAM_GetWPLockState (RRAMC_Type *base)
| Gets the state of write protection lock. More...
__STATIC_INLINE void | Cy_RRAM_SetVoltageMode (RRAMC_Type *base, cy_en_rram_vmode_t vmode)
| Set voltage/frequency mode. More...
__STATIC_INLINE cy_en_rram_vmode_t | Cy_RRAM_GetVoltageMode (RRAMC_Type *base)
| Get voltage/frequency mode. More...
__STATIC_INLINE void | Cy_RRAM_SetTemperature (RRAMC_Type *base, cy_en_rram_temperature_t temperature)
| Set junction temperature. More...
__STATIC_INLINE cy_en_rram_temperature_t | Cy_RRAM_GetTemperature (RRAMC_Type *base)
| Get junction temperature. More...
cy_en_rram_status_t | Cy_RRAM_SetProtLockableRegion (RRAMC_Type *base, uint32_t regionSize)
| Sets the size of lockable region in PROTECTED_NVM region. More...
__STATIC_INLINE uint32_t | Cy_RRAM_GetProtLockableRegion (RRAMC_Type *base)
| Gets the size of configured lockable region in PROTECTED_NVM region. More...
__STATIC_INLINE void | Cy_RRAM_SetProtLock (RRAMC_Type *base)
| Enables the lock for the configured PROTECTED_NVM region Cy_RRAM_SetProtLockableRegion(). More...
__STATIC_INLINE cy_en_rram_protected_lock_t | Cy_RRAM_GetProtLockState (RRAMC_Type *base)
| Get the lock state of the PROTECTED_NVM Lockable region. More...
__STATIC_INLINE void | Cy_RRAM_SetUDSLock (RRAMC_Type *base)
| Enables the lock to avoid access to UDS key. More...
__STATIC_INLINE cy_en_rram_uds_lock_t | Cy_RRAM_GetUDSLockState (RRAMC_Type *base)
| Get the status of UDS lock. More...
__STATIC_INLINE void | Cy_RRAM_SetUDSConfig (RRAMC_Type *base, bool config)
| Configure UDS to trigger a AHB error or read as zero without error when there is a read access to UDS. More...
__STATIC_INLINE void | Cy_RRAM_ForceRelPCLock (RRAMC_Type *base)
| Release PC lock forcefully. More...

## Function Documentation

## ◆ Cy_RRAM_OtpWriteByteArray()

cy_en_rram_status_t Cy_RRAM_OtpWriteByteArray | ( | RRAMC_Type * | base,
|  | uint32_t | addr,
|  | const uint8_t * | data,
|  | uint32_t | numBytes
| ) |  |

Writes array of byte data to the specified address.

This function tries to acquire the lock. If the lock is not available, then it returns immediately with CY_RRAM_ACQUIRE_PC_LOCK_FAIL error.

Parameters

  base | The pointer to the RRAMC instance.
  addr | Address of the OTP subsection. The address should fall in General OTP or Protected OTP subsection.
  data | Pointer to the data to be written to the specified address.
  numBytes | Number of bytes to be written.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  #if (CY_IP_MXS22RRAMC_VERSION == 1u)
  uint32_t addr = CY_RRAM_PROTECTED_OTP_PROTECTED_S_START_ADDRESS + 0x12UL;
  #else
  uint32_t addr = CY_RRAM_GENERAL_OTP_MMIO_S_START_ADDRESS + 0x12UL;
  #endif
  uint8_t data[8U] = {0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x06U, 0x07U, 0x08U};
  uint32_t numBytes = 8UL;
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Writes array of byte to the specified address. */
  cy_en_rram_status_t status = Cy_RRAM_OtpWriteByteArray(base, addr, data, numBytes);
  cy_en_rram_status_t
  cy_en_rram_status_t
  RRAM driver error codes.
  Definition: cy_rram.h:234
  Cy_RRAM_OtpWriteByteArray
  cy_en_rram_status_t Cy_RRAM_OtpWriteByteArray(RRAMC_Type *base, uint32_t addr, const uint8_t *data, uint32_t numBytes)
  Writes array of byte data to the specified address.
  Definition: cy_rram.c:820
  RRAMC_Type
  RRAM controller registers (RRAMC)
  Definition: cyip_rramc.h:117

Note
  OTP region is One Time Programmable. API does read-modify(OR)-write operation. Once the data bit has been programmed into the OTP region it can't be erased by writing a 0 to it. Any zero bit in the data indicates that write to this bit in OTP regions will be ignored.

The address should fall in General OTP or Protected OTP subsection.

## ◆ Cy_RRAM_OtpReadByteArray()

cy_en_rram_status_t Cy_RRAM_OtpReadByteArray | ( | RRAMC_Type * | base,
|  | uint32_t | addr,
|  | uint8_t * | data,
|  | uint32_t | numBytes
| ) |  |

Reads array of byte data from the specified address.

Parameters

  base | The pointer to the RRAMC instance.
  addr | Address of the OTP subsection. The address should fall in General OTP or Protected OTP subsection.
  data | Pointer to the destination where the read data is stored.
  numBytes | Number of bytes to be read.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  #define NUM_BYTES (0x8)
  uint32_t addr = CY_RRAM_GENERAL_OTP_MMIO_NS_START_ADDRESS + 0x12UL;
  uint8_t data[NUM_BYTES];
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Reads array of byte data from the specified address. */
  cy_en_rram_status_t status = Cy_RRAM_OtpReadByteArray(base, addr, data, NUM_BYTES);
  Cy_RRAM_OtpReadByteArray
  cy_en_rram_status_t Cy_RRAM_OtpReadByteArray(RRAMC_Type *base, uint32_t addr, uint8_t *data, uint32_t numBytes)
  Reads array of byte data from the specified address.
  Definition: cy_rram.c:860

The address should fall in General OTP or Protected OTP subsection.

## ◆ Cy_RRAM_OtpWriteWord()

cy_en_rram_status_t Cy_RRAM_OtpWriteWord | ( | RRAMC_Type * | base,
|  | uint32_t | addr,
|  | uint32_t | data
| ) |  |

Writes a 32-bit word data to the specified address.

This function tries to acquire the lock. If the lock is not available, then it returns immediately with CY_RRAM_ACQUIRE_PC_LOCK_FAIL error.

Parameters

  base | The pointer to the RRAMC instance.
  addr | Address of the OTP subsection. The address should fall in General OTP or Protected OTP subsection.
  data | Data to be written to the specified address.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  #if (CY_IP_MXS22RRAMC_VERSION == 1u)
  uint32_t addr = CY_RRAM_PROTECTED_OTP_PROTECTED_S_START_ADDRESS + 0x12UL;
  #else
  uint32_t addr = CY_RRAM_GENERAL_OTP_MMIO_S_START_ADDRESS + 0x12UL;
  #endif
  uint32_t data = 0x01020304UL;
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Writes a 32-bit word data to the specified address. */
  cy_en_rram_status_t status = Cy_RRAM_OtpWriteWord(base, addr, data);
  Cy_RRAM_OtpWriteWord
  cy_en_rram_status_t Cy_RRAM_OtpWriteWord(RRAMC_Type *base, uint32_t addr, uint32_t data)
  Writes a 32-bit word data to the specified address.
  Definition: cy_rram.c:883

Note
  OTP region is One Time Programmable. API does read-modify(OR)-write operation. Once the data bit has been programmed into the OTP region it can't be erased by writing a 0 to it. Any zero bit in the data indicates that write to this bit in OTP regions will be ignored.

The address should fall in General OTP or Protected OTP subsection.

## ◆ Cy_RRAM_OtpReadWord()

cy_en_rram_status_t Cy_RRAM_OtpReadWord | ( | RRAMC_Type * | base,
|  | uint32_t | addr,
|  | uint32_t * | data
| ) |  |

Reads a 32bit word data from the specified address.

Parameters

  base | The pointer to the RRAMC instance.
  addr | Address of the OTP subsection. The address should fall in General OTP or Protected OTP subsection.
  data | Pointer to the destination where the read word is stored.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  uint32_t addr = CY_RRAM_GENERAL_OTP_MMIO_S_START_ADDRESS + 0x12UL;
  uint32_t data;
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Reads a word data from the specified address.*/
  cy_en_rram_status_t status = Cy_RRAM_OtpReadWord(base, addr, &data);
  Cy_RRAM_OtpReadWord
  cy_en_rram_status_t Cy_RRAM_OtpReadWord(RRAMC_Type *base, uint32_t addr, uint32_t *data)
  Reads a 32bit word data from the specified address.
  Definition: cy_rram.c:897

The address should fall in General OTP or Protected OTP subsection.

## ◆ Cy_RRAM_OtpWriteBlock()

cy_en_rram_status_t Cy_RRAM_OtpWriteBlock | ( | RRAMC_Type * | base,
|  | uint32_t | addr,
|  | uint8_t * | data
| ) |  |

Writes a block(16B) data to the specified address.

Assumption is that the provided address is block aligned. This function tries to acquire the lock. If the lock is not available, then it returns immediately with CY_RRAM_ACQUIRE_PC_LOCK_FAIL error.

Parameters

  base | The pointer to the RRAMC instance.
  addr | Address of the OTP subsection. The address should fall in General OTP or Protected OTP subsection.
  data | Pointer to the data to be written to the specified address.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  #if (CY_IP_MXS22RRAMC_VERSION == 1u)
  uint32_t addr = CY_RRAM_PROTECTED_OTP_PROTECTED_S_START_ADDRESS + 0x12UL;
  #else
  uint32_t addr = CY_RRAM_GENERAL_OTP_MMIO_S_START_ADDRESS + 0x12UL;
  #endif
  uint8_t data[CY_RRAM_BLOCK_SIZE_BYTES];
  RRAMC_Type * base = RRAMC0;
  for (uint32_t i=0; i<CY_RRAM_BLOCK_SIZE_BYTES; i++)
  {
  data[i] = i+1;
  }
  /* Scenario: Writes a 16B block data to the specified address. */
  cy_en_rram_status_t status = Cy_RRAM_OtpWriteBlock(base, addr, data);
  Cy_RRAM_OtpWriteBlock
  cy_en_rram_status_t Cy_RRAM_OtpWriteBlock(RRAMC_Type *base, uint32_t addr, uint8_t *data)
  Writes a block(16B) data to the specified address.
  Definition: cy_rram.c:912

Note
  OTP region is One Time Programmable. API does read-modify(OR)-write operation.

The address should be block aligned. The address should fall in General OTP or Protected OTP subsection.

## ◆ Cy_RRAM_NvmWriteByteArray()

cy_en_rram_status_t Cy_RRAM_NvmWriteByteArray | ( | RRAMC_Type * | base,
|  | uint32_t | addr,
|  | const uint8_t * | data,
|  | uint32_t | numBytes
| ) |  |

Writes array of byte data to the specified address in blocking mode.

API will wait for the write operation to be completed. It returns error or success status. This function tries to acquire the lock. If the lock is not available, then it returns immediately with CY_RRAM_ACQUIRE_PC_LOCK_FAIL error.

Parameters

  base | The pointer to the RRAMC instance.
  addr | Address of the NVM subsection. The address should fall in Main or Work or Sflash or Protected NVM subsection.
  data | Pointer to the data to be written to the specified address.
  numBytes | Number of bytes to be written.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  uint32_t addr = CY_RRAM_MAIN_HOST_NS_START_ADDRESS + 0x12UL;
  uint8_t data[8U] = {0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x06U, 0x07U, 0x08U};
  uint32_t numBytes = 8UL;
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Writes array of byte to the specified address in Blocking mode. */
  cy_en_rram_status_t status = Cy_RRAM_NvmWriteByteArray(base, addr, data, numBytes);
  Cy_RRAM_NvmWriteByteArray
  cy_en_rram_status_t Cy_RRAM_NvmWriteByteArray(RRAMC_Type *base, uint32_t addr, const uint8_t *data, uint32_t numBytes)
  Writes array of byte data to the specified address in blocking mode.
  Definition: cy_rram.c:933

The address should fall in Main or Work or Sflash or Protected NVM subsection.

## ◆ Cy_RRAM_NvmReadByteArray()

cy_en_rram_status_t Cy_RRAM_NvmReadByteArray | ( | RRAMC_Type * | base,
|  | uint32_t | addr,
|  | uint8_t * | data,
|  | uint32_t | numBytes
| ) |  |

Reads array of byte data from the specified address.

Parameters

  base | The pointer to the RRAMC instance.
  addr | Address of the NVM subsection. The address should fall in Main or Work or Sflash or Protected NVM subsection.
  data | Pointer to the destination where the read data is stored.
  numBytes | Number of bytes to be read.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  #define NUM_BYTES (0x8)
  uint32_t addr = CY_RRAM_MAIN_HOST_NS_START_ADDRESS + 0x12UL;
  uint8_t data[NUM_BYTES];
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Reads array of byte data from the specified address. */
  cy_en_rram_status_t status = Cy_RRAM_NvmReadByteArray(base, addr, data, NUM_BYTES);
  Cy_RRAM_NvmReadByteArray
  cy_en_rram_status_t Cy_RRAM_NvmReadByteArray(RRAMC_Type *base, uint32_t addr, uint8_t *data, uint32_t numBytes)
  Reads array of byte data from the specified address.
  Definition: cy_rram.c:973

The address should fall in Main, Work, Sflash, Protected NVM subsection.

## ◆ Cy_RRAM_NonBlockingNvmWriteByteArray()

cy_en_rram_status_t Cy_RRAM_NonBlockingNvmWriteByteArray | ( | RRAMC_Type * | base,
|  | uint32_t | addr,
|  | const uint8_t * | data,
|  | uint32_t | numBytes
| ) |  |

Writes array of byte data to the specified address in Non Blocking mode.

API will only validate parameter and performs write operation. User needs to call Cy_RRAM_GetStatus() to check the status of write operation. This function tries to acquire the lock. If the lock is not available, then it returns immediately with CY_RRAM_ACQUIRE_PC_LOCK_FAIL error.

Parameters

  base | The pointer to the RRAMC instance.
  addr | Address of the NVM subsection. The address should fall in Main or Work or Sflash or Protected NVM subsection.
  data | Pointer to the data to be written to the specified address.
  numBytes | Number of bytes to be written.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  uint32_t addr = CY_RRAM_MAIN_HOST_NS_START_ADDRESS + 0x12UL;
  uint8_t data[8U] = {0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x06U, 0x07U, 0x08U};
  uint32_t numBytes = 8UL;
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Writes array of byte to the specified address in Non-Blocking mode. */
  cy_en_rram_status_t status = Cy_RRAM_NonBlockingNvmWriteByteArray(base, addr, data, numBytes);
  /* Check the error status for the non-blocking mode */
  uint32_t errorStatus = Cy_RRAM_GetStatus(base);
  cy_en_rram_hresp_t ahbError = Cy_RRAM_GetAHBError(base);
  cy_en_rram_hresp_t
  cy_en_rram_hresp_t
  RRAM AHB error codes.
  Definition: cy_rram.h:321
  Cy_RRAM_GetStatus
  __STATIC_INLINE uint32_t Cy_RRAM_GetStatus(RRAMC_Type *base)
  Get the status of RRAM.
  Definition: cy_rram.h:855
  Cy_RRAM_NonBlockingNvmWriteByteArray
  cy_en_rram_status_t Cy_RRAM_NonBlockingNvmWriteByteArray(RRAMC_Type *base, uint32_t addr, const uint8_t *data, uint32_t numBytes)
  Writes array of byte data to the specified address in Non Blocking mode.
  Definition: cy_rram.c:996
  Cy_RRAM_GetAHBError
  __STATIC_INLINE cy_en_rram_hresp_t Cy_RRAM_GetAHBError(RRAMC_Type *base)
  Gets AHB bus error occurred during transactions.
  Definition: cy_rram.h:899

The address should fall in Main or Work or Sflash or Protected NVM subsection.

## ◆ Cy_RRAM_NvmWriteBlock()

cy_en_rram_status_t Cy_RRAM_NvmWriteBlock | ( | RRAMC_Type * | base,
|  | uint32_t | addr,
|  | uint8_t * | data
| ) |  |

Writes a block(16B) data to the specified address.

Assumption is that the provided address is Block aligned. This function tries to acquire the lock. If the lock is not available, then it returns immediately with CY_RRAM_ACQUIRE_PC_LOCK_FAIL error.

Parameters

  base | The pointer to the RRAMC instance.
  addr | Address of the NVM subsection. The address should fall in Main or Work or Sflash or Protected NVM subsection.
  data | Pointer to the data to be written to the specified address.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  uint32_t addr = CY_RRAM_MAIN_HOST_NS_START_ADDRESS;
  uint8_t data[CY_RRAM_BLOCK_SIZE_BYTES];
  RRAMC_Type * base = RRAMC0;
  for (uint32_t i=0; i<CY_RRAM_BLOCK_SIZE_BYTES; i++)
  {
  data[i] = i+1;
  }
  /* Scenario: Writes a 16B block data to the specified address. */
  cy_en_rram_status_t status = Cy_RRAM_OtpWriteBlock(base, addr, data);

Writes a block(16B) data to the specified address.

The address should fall in Main or Work or Sflash or Protected NVM subsection.

## ◆ Cy_RRAM_WriteByteArray()

cy_en_rram_status_t Cy_RRAM_WriteByteArray | ( | RRAMC_Type * | base,
|  | uint32_t | addr,
|  | const uint8_t * | data,
|  | uint32_t | numBytes
| ) |  |

Writes array of byte data to the specified address in blocking mode.

API will wait for the write operation to be completed. It returns error or success status. This function tries to acquire the lock. If the lock is not available, then it returns immediately with CY_RRAM_ACQUIRE_PC_LOCK_FAIL error.

Parameters

  base | The pointer to the RRAMC instance.
  addr | Address of RRAM memory. The provided address should fall under one of the NVM or OTP sub sections otherwise bad parameter error will be returned.
  data | Pointer to the data to be written to the specified address.
  numBytes | Number of bytes to be written.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  uint32_t addr = CY_RRAM_MAIN_HOST_NS_START_ADDRESS + 0x12UL;
  uint8_t data[8U] = {0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x06U, 0x07U, 0x08U};
  uint32_t numBytes = 8UL;
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Writes array of byte data to the specified address. */
  cy_en_rram_status_t status = Cy_RRAM_WriteByteArray(base, addr, data, numBytes);
  Cy_RRAM_WriteByteArray
  cy_en_rram_status_t Cy_RRAM_WriteByteArray(RRAMC_Type *base, uint32_t addr, const uint8_t *data, uint32_t numBytes)
  Writes array of byte data to the specified address in blocking mode.
  Definition: cy_rram.c:1057

Note
  OTP region is One Time Programmable. API does read-modify(OR)-write operation.

Writes array of byte data to the specified address in blocking mode.

API will wait for the write operation to be completed. It returns error or success status.

## ◆ Cy_RRAM_TSWriteByteArray()

cy_en_rram_status_t Cy_RRAM_TSWriteByteArray | ( | RRAMC_Type * | base,
|  | uint32_t | addr,
|  | const uint8_t * | data,
|  | uint32_t | numBytes
| ) |  |

Writes an array of byte data to the specified address in blocking mode without considering uncorrectable ECC fail error.

API will wait for the write operation to be completed. It returns error or success status. This function tries to acquire the lock. If the lock is not available, then it returns immediately with CY_RRAM_ACQUIRE_PC_LOCK_FAIL error.

Parameters

  base | The pointer to the RRAMC instance.
  addr | Address of RRAM memory. The provided address should fall under one of the NVM or OTP sub sections otherwise bad parameter error will be returned.
  data | Pointer to the data to be written to the specified address.
  numBytes | Number of bytes to be written.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  uint32_t addr = CY_RRAM_MAIN_HOST_NS_START_ADDRESS + 0x12UL;
  uint8_t data[8U] = {0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x06U, 0x07U, 0x08U};
  uint32_t numBytes = 8UL;
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Writes array of byte data to the specified address. */
  cy_en_rram_status_t status = Cy_RRAM_TSWriteByteArray(base, addr, data, numBytes);
  Cy_RRAM_TSWriteByteArray
  cy_en_rram_status_t Cy_RRAM_TSWriteByteArray(RRAMC_Type *base, uint32_t addr, const uint8_t *data, uint32_t numBytes)
  Writes an array of byte data to the specified address in blocking mode without considering uncorrecta...
  Definition: cy_rram.c:1086

Note
  This API should be used only for tearing safe use cases.

This API should be used only for tearing safe use cases.

## ◆ Cy_RRAM_ReadByteArray()

cy_en_rram_status_t Cy_RRAM_ReadByteArray | ( | RRAMC_Type * | base,
|  | uint32_t | addr,
|  | uint8_t * | data,
|  | uint32_t | numBytes
| ) |  |

Reads an array of byte data from the specified address.

Parameters

  base | The pointer to the RRAMC instance.
  addr | Address of RRAM memory. The provided address should fall under one of the NVM or OTP sub sections otherwise bad parameter error will be returned.
  data | Pointer to the destination where the read data is stored.
  numBytes | Number of bytes to be read.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  uint32_t addr = CY_RRAM_MAIN_HOST_NS_START_ADDRESS + 0x12UL;
  uint8_t data[8U];
  uint32_t numBytes = 8UL;
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Reads a array of byte data from the address. */
  cy_en_rram_status_t status = Cy_RRAM_ReadByteArray(base, addr, data, numBytes);
  Cy_RRAM_ReadByteArray
  cy_en_rram_status_t Cy_RRAM_ReadByteArray(RRAMC_Type *base, uint32_t addr, uint8_t *data, uint32_t numBytes)
  Reads an array of byte data from the specified address.
  Definition: cy_rram.c:1160

Reads an array of byte data from the specified address.

## ◆ Cy_RRAM_TSReadByteArray()

cy_en_rram_status_t Cy_RRAM_TSReadByteArray | ( | RRAMC_Type * | base,
|  | uint32_t | addr,
|  | uint8_t * | data,
|  | uint32_t | numBytes
| ) |  |

Reads an array of byte data from the specified address after validating the uncorrectable ECC fail bits.

Returns ECC fail error if uncorrectable ECC fail error exist. This function tries to acquire the lock. If the lock is not available, then it returns immediately with CY_RRAM_ACQUIRE_PC_LOCK_FAIL error.

Parameters

  base | The pointer to the RRAMC instance.
  addr | Address of RRAM memory. The provided address should fall under one of the NVM or OTP sub sections otherwise bad parameter error will be returned.
  data | Pointer to the destination where the read data is stored.
  numBytes | Number of bytes to be read.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  uint32_t addr = CY_RRAM_MAIN_HOST_NS_START_ADDRESS + 0x12UL;
  uint8_t data[8U];
  uint32_t numBytes = 8UL;
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Reads a array of byte data from the address. */
  cy_en_rram_status_t status = Cy_RRAM_ReadByteArray(base, addr, data, numBytes);

Function Usage
  uint32_t addr = CY_RRAM_MAIN_HOST_NS_START_ADDRESS + 0x12UL;
  uint8_t data[8U];
  uint32_t numBytes = 8UL;
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Reads a array of byte data from the address. */
  cy_en_rram_status_t status = Cy_RRAM_TSReadByteArray(base, addr, data, numBytes);
  Cy_RRAM_TSReadByteArray
  cy_en_rram_status_t Cy_RRAM_TSReadByteArray(RRAMC_Type *base, uint32_t addr, uint8_t *data, uint32_t numBytes)
  Reads an array of byte data from the specified address after validating the uncorrectable ECC fail bi...
  Definition: cy_rram.c:1190

Note
  This API should be used only for tearing safe use cases.

Returns ECC fail error if uncorrectable ECC fail error exist. This API should be used only for tearing safe use cases.

## ◆ Cy_RRAM_Init()

cy_en_rram_status_t Cy_RRAM_Init | ( | RRAMC_Type * | base,
|  | cy_en_rram_vmode_t | vmode,
|  | bool | retrvAlgoInfo
| ) |  |

Retrieves configuration settings from configuration space in extra area.

Sequence followed: Set voltage/frequency mode cy_en_rram_vmode_t Start "Retrieve configuration settings" sequence and waits until the sequence finishes. Validate for read errors and return status.

Parameters

  base | The pointer to the RRAMC instance.
  vmode | voltage/frequency mode for operations.
  retrvAlgoInfo | Set the parameter to true in order to retrieve the write algorithm information along with the SYSCONF information and configuration settings.

Returns
  Status. Refer cy_en_rram_status_t

Note
  This API is available only for CM0P

## ◆ Cy_RRAM_GetStatus()

__STATIC_INLINE uint32_t Cy_RRAM_GetStatus | ( | RRAMC_Type * | base | ) |

Get the status of RRAM.

It includes information about busy status, sleep status, status on ECC during read operation, write protection error.

Parameters

  base | The pointer to the RRAMC instance.

Returns
  RRAM status.

Function Usage
  uint32_t addr = CY_RRAM_MAIN_HOST_NS_START_ADDRESS + 0x12UL;
  uint8_t data[8U] = {0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x06U, 0x07U, 0x08U};
  uint32_t numBytes = 8UL;
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Writes array of byte to the specified address in Non-Blocking mode. */
  cy_en_rram_status_t status = Cy_RRAM_NonBlockingNvmWriteByteArray(base, addr, data, numBytes);
  /* Check the error status for the non-blocking mode */
  uint32_t errorStatus = Cy_RRAM_GetStatus(base);
  cy_en_rram_hresp_t ahbError = Cy_RRAM_GetAHBError(base);

## ◆ Cy_RRAM_IsBusy()

__STATIC_INLINE bool Cy_RRAM_IsBusy | ( | RRAMC_Type * | base | ) |

Indicates the status of NVM Busy flag.

Parameters

  base | The pointer to the RRAMC instance.

Returns
  RRAM status: true - Busy, false - Not busy.

## ◆ Cy_RRAM_GetAHBError()

__STATIC_INLINE cy_en_rram_hresp_t Cy_RRAM_GetAHBError | ( | RRAMC_Type * | base | ) |

Gets AHB bus error occurred during transactions.

Parameters

  base | The pointer to the RRAMC instance.

Returns
  Status. Refer cy_en_rram_hresp_t

Function Usage
  uint32_t addr = CY_RRAM_MAIN_HOST_NS_START_ADDRESS + 0x12UL;
  uint8_t data[8U] = {0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x06U, 0x07U, 0x08U};
  uint32_t numBytes = 8UL;
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Writes array of byte to the specified address in Non-Blocking mode. */
  cy_en_rram_status_t status = Cy_RRAM_NonBlockingNvmWriteByteArray(base, addr, data, numBytes);
  /* Check the error status for the non-blocking mode */
  uint32_t errorStatus = Cy_RRAM_GetStatus(base);
  cy_en_rram_hresp_t ahbError = Cy_RRAM_GetAHBError(base);

## ◆ Cy_RRAM_EnableSleepMode()

__STATIC_INLINE void Cy_RRAM_EnableSleepMode | ( | RRAMC_Type * | base | ) |

Puts RRAM in Sleep mode.

No memory access is possible in NVM sleep mode. During sleep, the SFR NVM_CONF1 can be read and written, all other SFRs are read-only.

Parameters

  base | The pointer to the RRAMC instance.

Function Usage
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Enable/Disable RRAM sleep mode. */
  cy_en_rram_sleep_t status = Cy_RRAM_GetSleepStatus(base);
  if(status == CY_RRAM_NOT_IN_SLEEP)
  {
  Cy_RRAM_EnableSleepMode(base);
  }
  if(status == CY_RRAM_IN_SLEEP)
  {
  Cy_RRAM_DisableSleepMode(base);
  }
  cy_en_rram_sleep_t
  cy_en_rram_sleep_t
  RRAM sleep mode status.
  Definition: cy_rram.h:282
  CY_RRAM_IN_SLEEP
  @ CY_RRAM_IN_SLEEP
  In sleep mode, or busy due to a sleep or wake up procedure.
  Definition: cy_rram.h:284
  CY_RRAM_NOT_IN_SLEEP
  @ CY_RRAM_NOT_IN_SLEEP
  Not in sleep mode, and no sleep or wake up procedure in progress.
  Definition: cy_rram.h:283
  Cy_RRAM_GetSleepStatus
  __STATIC_INLINE cy_en_rram_sleep_t Cy_RRAM_GetSleepStatus(RRAMC_Type *base)
  Gets the sleep status of RRAM.
  Definition: cy_rram.h:969
  Cy_RRAM_EnableSleepMode
  __STATIC_INLINE void Cy_RRAM_EnableSleepMode(RRAMC_Type *base)
  Puts RRAM in Sleep mode.
  Definition: cy_rram.h:922
  Cy_RRAM_DisableSleepMode
  __STATIC_INLINE void Cy_RRAM_DisableSleepMode(RRAMC_Type *base)
  Puts RRAM in Normal mode.
  Definition: cy_rram.h:944

## ◆ Cy_RRAM_DisableSleepMode()

__STATIC_INLINE void Cy_RRAM_DisableSleepMode | ( | RRAMC_Type * | base | ) |

Puts RRAM in Normal mode.

Parameters

  base | The pointer to the RRAMC instance.

Function Usage
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Enable/Disable RRAM sleep mode. */
  cy_en_rram_sleep_t status = Cy_RRAM_GetSleepStatus(base);
  if(status == CY_RRAM_NOT_IN_SLEEP)
  {
  Cy_RRAM_EnableSleepMode(base);
  }
  if(status == CY_RRAM_IN_SLEEP)
  {
  Cy_RRAM_DisableSleepMode(base);
  }

## ◆ Cy_RRAM_GetSleepStatus()

__STATIC_INLINE cy_en_rram_sleep_t Cy_RRAM_GetSleepStatus | ( | RRAMC_Type * | base | ) |

Gets the sleep status of RRAM.

Parameters

  base | The pointer to the RRAMC instance.

Returns
  Status. Refer cy_en_rram_sleep_t

Function Usage
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Enable/Disable RRAM sleep mode. */
  cy_en_rram_sleep_t status = Cy_RRAM_GetSleepStatus(base);
  if(status == CY_RRAM_NOT_IN_SLEEP)
  {
  Cy_RRAM_EnableSleepMode(base);
  }
  if(status == CY_RRAM_IN_SLEEP)
  {
  Cy_RRAM_DisableSleepMode(base);
  }

## ◆ Cy_RRAM_EnableWP()

cy_en_rram_status_t Cy_RRAM_EnableWP | ( | RRAMC_Type * | base,
|  | uint32_t | numSectors
| ) |  |

Enables write protection for number of sectors starting with sector 0 in RRAM NVM region.

Before calling this API, user need to call Cy_RRAM_GetWPLockState() API and make sure the write protection lock is not locked. Otherwise this API will return CY_RRAM_WPLOCK_ENABLED error.

Parameters

  base | The pointer to the RRAMC instance.
  numSectors | Number of sectors.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  #define NUM_BYTES (0x10)
  /* Number of sectors to be write protected. */
  uint32_t addr = CY_RRAM_MAIN_HOST_S_START_ADDRESS;
  uint32_t numSectors = 4UL;
  cy_en_rram_status_t status = CY_RRAM_WPLOCK_ENABLED;
  RRAMC_Type * base = RRAMC0;
  uint8_t writeData[NUM_BYTES];
  uint8_t readData[NUM_BYTES];
  for (uint32_t i=0; i<NUM_BYTES; i++)
  {
  writeData[i] = 2;
  }
  /* Scenario: Enable Write Protection for NVM sectors. */
  if(Cy_RRAM_GetWPLockState(base) == CY_RRAM_WP_UNLOCK)
  {
  status = Cy_RRAM_EnableWP(base, numSectors);
  }
  if(status == CY_RRAM_SUCCESS)
  {
  //Perform write operation on the write protected memory.
  status = Cy_RRAM_NvmWriteByteArray(base, addr, writeData, NUM_BYTES);
  // Read back the written data
  status = Cy_RRAM_NvmReadByteArray(base, addr, readData, NUM_BYTES);
  //Read and written data should not match
  if(memcmp(&writeData, &readData, sizeof(writeData)) == 0)
  {
  // Test case failed.
  }
  else
  {
  // Test case success.
  }
  }
  /* Scenario: Disable Write Protection for NVM sectors. */
  status = Cy_RRAM_DisableWP(base);
  if(status == CY_RRAM_SUCCESS)
  {
  //Perform write operation on the memory.
  status = Cy_RRAM_NvmWriteByteArray(base, addr, writeData, NUM_BYTES);
  // Read back the written data
  status = Cy_RRAM_NvmReadByteArray(base, addr, readData, NUM_BYTES);
  //Read and written data should match, since there is no write protection
  if(memcmp(&writeData, &readData, sizeof(writeData)) == 0)
  {
  // Test case success.
  }
  else
  {
  // Test case failed.
  }
  }
  CY_RRAM_WP_UNLOCK
  @ CY_RRAM_WP_UNLOCK
  Not locked, Sectors for write protection can be configured.
  Definition: cy_rram.h:273
  CY_RRAM_WPLOCK_ENABLED
  @ CY_RRAM_WPLOCK_ENABLED
  Write protection lock enabled.
  Definition: cy_rram.h:240
  CY_RRAM_SUCCESS
  @ CY_RRAM_SUCCESS
  Returned successful.
  Definition: cy_rram.h:235
  Cy_RRAM_EnableWP
  cy_en_rram_status_t Cy_RRAM_EnableWP(RRAMC_Type *base, uint32_t numSectors)
  Enables write protection for number of sectors starting with sector 0 in RRAM NVM region.
  Definition: cy_rram.c:1327
  Cy_RRAM_DisableWP
  cy_en_rram_status_t Cy_RRAM_DisableWP(RRAMC_Type *base)
  Disables write protection for all sectors in RRAM NVM region.
  Definition: cy_rram.c:1364
  Cy_RRAM_GetWPLockState
  __STATIC_INLINE cy_en_rram_wp_lock_t Cy_RRAM_GetWPLockState(RRAMC_Type *base)
  Gets the state of write protection lock.
  Definition: cy_rram.h:1067

Before calling this API, user need to call Cy_RRAM_GetWPLockState() API and make sure the write protection lock is not locked. Otherwise this API will return CY_RRAM_WPLOCK_ENABLED error.

## ◆ Cy_RRAM_DisableWP()

cy_en_rram_status_t Cy_RRAM_DisableWP | ( | RRAMC_Type * | base | ) |

Disables write protection for all sectors in RRAM NVM region.

Before calling this API, user need to call Cy_RRAM_GetWPLockState() API and make sure the write protection lock is not locked. Otherwise this API will return CY_RRAM_WPLOCK_ENABLED error.

Parameters

  base | The pointer to the RRAMC instance.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  #define NUM_BYTES (0x10)
  /* Number of sectors to be write protected. */
  uint32_t addr = CY_RRAM_MAIN_HOST_S_START_ADDRESS;
  uint32_t numSectors = 4UL;
  cy_en_rram_status_t status = CY_RRAM_WPLOCK_ENABLED;
  RRAMC_Type * base = RRAMC0;
  uint8_t writeData[NUM_BYTES];
  uint8_t readData[NUM_BYTES];
  for (uint32_t i=0; i<NUM_BYTES; i++)
  {
  writeData[i] = 2;
  }
  /* Scenario: Enable Write Protection for NVM sectors. */
  if(Cy_RRAM_GetWPLockState(base) == CY_RRAM_WP_UNLOCK)
  {
  status = Cy_RRAM_EnableWP(base, numSectors);
  }
  if(status == CY_RRAM_SUCCESS)
  {
  //Perform write operation on the write protected memory.
  status = Cy_RRAM_NvmWriteByteArray(base, addr, writeData, NUM_BYTES);
  // Read back the written data
  status = Cy_RRAM_NvmReadByteArray(base, addr, readData, NUM_BYTES);
  //Read and written data should not match
  if(memcmp(&writeData, &readData, sizeof(writeData)) == 0)
  {
  // Test case failed.
  }
  else
  {
  // Test case success.
  }
  }
  /* Scenario: Disable Write Protection for NVM sectors. */
  status = Cy_RRAM_DisableWP(base);
  if(status == CY_RRAM_SUCCESS)
  {
  //Perform write operation on the memory.
  status = Cy_RRAM_NvmWriteByteArray(base, addr, writeData, NUM_BYTES);
  // Read back the written data
  status = Cy_RRAM_NvmReadByteArray(base, addr, readData, NUM_BYTES);
  //Read and written data should match, since there is no write protection
  if(memcmp(&writeData, &readData, sizeof(writeData)) == 0)
  {
  // Test case success.
  }
  else
  {
  // Test case failed.
  }
  }

Before calling this API, user need to call Cy_RRAM_GetWPLockState() API and make sure the write protection lock is not locked. Otherwise this API will return CY_RRAM_WPLOCK_ENABLED error.

## ◆ Cy_RRAM_SetWPLock()

__STATIC_INLINE void Cy_RRAM_SetWPLock | ( | RRAMC_Type * | base | ) |

Enables the write protection lock by setting WPLCK to 1.

Once locked, the lock state cannot be changed till next reset.

Parameters

  base | The pointer to the RRAMC instance.

Function Usage
  #define NUM_BYTES (0x10)
  /* Number of sectors to be write protected. */
  uint32_t addr = CY_RRAM_MAIN_HOST_S_START_ADDRESS;
  uint32_t numSectors = 4UL;
  cy_en_rram_status_t status = CY_RRAM_WPLOCK_ENABLED;
  RRAMC_Type * base = RRAMC0;
  uint8_t writeData[NUM_BYTES];
  uint8_t readData[NUM_BYTES];
  for (uint32_t i=0; i<NUM_BYTES; i++)
  {
  writeData[i] = 2;
  }
  /* Scenario: Enable Write Protection for NVM sectors. */
  if(Cy_RRAM_GetWPLockState(base) == CY_RRAM_WP_UNLOCK)
  {
  status = Cy_RRAM_EnableWP(base, numSectors);
  }
  if(status == CY_RRAM_SUCCESS)
  {
  //Perform write operation on the write protected memory.
  status = Cy_RRAM_NvmWriteByteArray(base, addr, writeData, NUM_BYTES);
  // Read back the written data
  status = Cy_RRAM_NvmReadByteArray(base, addr, readData, NUM_BYTES);
  //Read and written data should not match
  if(memcmp(&writeData, &readData, sizeof(writeData)) == 0)
  {
  // Test case failed.
  }
  else
  {
  // Test case success.
  }
  }
  /* Scenario: Disable Write Protection for NVM sectors. */
  status = Cy_RRAM_DisableWP(base);
  if(status == CY_RRAM_SUCCESS)
  {
  //Perform write operation on the memory.
  status = Cy_RRAM_NvmWriteByteArray(base, addr, writeData, NUM_BYTES);
  // Read back the written data
  status = Cy_RRAM_NvmReadByteArray(base, addr, readData, NUM_BYTES);
  //Read and written data should match, since there is no write protection
  if(memcmp(&writeData, &readData, sizeof(writeData)) == 0)
  {
  // Test case success.
  }
  else
  {
  // Test case failed.
  }
  }

## ◆ Cy_RRAM_GetWPLockState()

__STATIC_INLINE cy_en_rram_wp_lock_t Cy_RRAM_GetWPLockState | ( | RRAMC_Type * | base | ) |

Gets the state of write protection lock.

Parameters

  base | The pointer to the RRAMC instance.

Returns
  Status. Refer cy_en_rram_wp_lock_t

Function Usage
  #define NUM_BYTES (0x10)
  /* Number of sectors to be write protected. */
  uint32_t addr = CY_RRAM_MAIN_HOST_S_START_ADDRESS;
  uint32_t numSectors = 4UL;
  cy_en_rram_status_t status = CY_RRAM_WPLOCK_ENABLED;
  RRAMC_Type * base = RRAMC0;
  uint8_t writeData[NUM_BYTES];
  uint8_t readData[NUM_BYTES];
  for (uint32_t i=0; i<NUM_BYTES; i++)
  {
  writeData[i] = 2;
  }
  /* Scenario: Enable Write Protection for NVM sectors. */
  if(Cy_RRAM_GetWPLockState(base) == CY_RRAM_WP_UNLOCK)
  {
  status = Cy_RRAM_EnableWP(base, numSectors);
  }
  if(status == CY_RRAM_SUCCESS)
  {
  //Perform write operation on the write protected memory.
  status = Cy_RRAM_NvmWriteByteArray(base, addr, writeData, NUM_BYTES);
  // Read back the written data
  status = Cy_RRAM_NvmReadByteArray(base, addr, readData, NUM_BYTES);
  //Read and written data should not match
  if(memcmp(&writeData, &readData, sizeof(writeData)) == 0)
  {
  // Test case failed.
  }
  else
  {
  // Test case success.
  }
  }
  /* Scenario: Disable Write Protection for NVM sectors. */
  status = Cy_RRAM_DisableWP(base);
  if(status == CY_RRAM_SUCCESS)
  {
  //Perform write operation on the memory.
  status = Cy_RRAM_NvmWriteByteArray(base, addr, writeData, NUM_BYTES);
  // Read back the written data
  status = Cy_RRAM_NvmReadByteArray(base, addr, readData, NUM_BYTES);
  //Read and written data should match, since there is no write protection
  if(memcmp(&writeData, &readData, sizeof(writeData)) == 0)
  {
  // Test case success.
  }
  else
  {
  // Test case failed.
  }
  }

## ◆ Cy_RRAM_SetVoltageMode()

__STATIC_INLINE void Cy_RRAM_SetVoltageMode | ( | RRAMC_Type * | base,
|  | cy_en_rram_vmode_t | vmode
| ) |  |

Set voltage/frequency mode.

Parameters

  base | The pointer to the RRAMC instance.
  vmode | Voltage mode. Refer cy_en_rram_vmode_t

Function Usage
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Update voltage/frequency mode. */
  /* Get the current mode */
  cy_en_rram_vmode_t mode = Cy_RRAM_GetVoltageMode(RRAMC0);
  /* Set mode to undefined */
  Cy_RRAM_SetVoltageMode(base, CY_RRAM_VMODE_UNDEFINED);
  if(CY_RRAM_VMODE_UNDEFINED == Cy_RRAM_GetVoltageMode(base))
  {
  // Updated to undefined mode
  }
  /* Set mode to MF */
  Cy_RRAM_SetVoltageMode(base, CY_RRAM_VMODE_HP);
  if(CY_RRAM_VMODE_HP == Cy_RRAM_GetVoltageMode(base))
  {
  //Updated to MF mode
  }
  else
  {
  //Failed to update to MF mode
  }
  Cy_RRAM_SetVoltageMode(base, mode);
  cy_en_rram_vmode_t
  cy_en_rram_vmode_t
  RRAM voltage/frequency mode for operations.
  Definition: cy_rram.h:344
  CY_RRAM_VMODE_HP
  @ CY_RRAM_VMODE_HP
  HP voltage/frequency mode for operations.
  Definition: cy_rram.h:348
  CY_RRAM_VMODE_UNDEFINED
  @ CY_RRAM_VMODE_UNDEFINED
  Undefined voltage/frequency mode for operations.
  Definition: cy_rram.h:345
  Cy_RRAM_GetVoltageMode
  __STATIC_INLINE cy_en_rram_vmode_t Cy_RRAM_GetVoltageMode(RRAMC_Type *base)
  Get voltage/frequency mode.
  Definition: cy_rram.h:1119
  Cy_RRAM_SetVoltageMode
  __STATIC_INLINE void Cy_RRAM_SetVoltageMode(RRAMC_Type *base, cy_en_rram_vmode_t vmode)
  Set voltage/frequency mode.
  Definition: cy_rram.h:1092

## ◆ Cy_RRAM_GetVoltageMode()

__STATIC_INLINE cy_en_rram_vmode_t Cy_RRAM_GetVoltageMode | ( | RRAMC_Type * | base | ) |

Get voltage/frequency mode.

Parameters

  base | The pointer to the RRAMC instance.

Returns
  Voltage mode. Refer cy_en_rram_vmode_t

Function Usage
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Update voltage/frequency mode. */
  /* Get the current mode */
  cy_en_rram_vmode_t mode = Cy_RRAM_GetVoltageMode(RRAMC0);
  /* Set mode to undefined */
  Cy_RRAM_SetVoltageMode(base, CY_RRAM_VMODE_UNDEFINED);
  if(CY_RRAM_VMODE_UNDEFINED == Cy_RRAM_GetVoltageMode(base))
  {
  // Updated to undefined mode
  }
  /* Set mode to MF */
  Cy_RRAM_SetVoltageMode(base, CY_RRAM_VMODE_HP);
  if(CY_RRAM_VMODE_HP == Cy_RRAM_GetVoltageMode(base))
  {
  //Updated to MF mode
  }
  else
  {
  //Failed to update to MF mode
  }
  Cy_RRAM_SetVoltageMode(base, mode);

## ◆ Cy_RRAM_SetTemperature()

__STATIC_INLINE void Cy_RRAM_SetTemperature | ( | RRAMC_Type * | base,
|  | cy_en_rram_temperature_t | temperature
| ) |  |

Set junction temperature.

Parameters

  base | The pointer to the RRAMC instance.
  temperature | Temperature. Refer cy_en_rram_temperature_t

Function Usage
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Update junction temperature. */
  /* Get the current temperature */
  cy_en_rram_temperature_t temperature = Cy_RRAM_GetTemperature(RRAMC0);
  /* Set temperature to Invalid temperature */
  Cy_RRAM_SetTemperature(base, CY_RRAM_TEMP_INVALID);
  temperature = Cy_RRAM_GetTemperature(RRAMC0);
  if(CY_RRAM_TEMP_INVALID == temperature)
  {
  // Updated to Invalid temperature
  }
  /* SSet temperature to MF */
  Cy_RRAM_SetTemperature(base, CY_RRAM_TEMP_ABOVE_85C_BELOW_100C);
  temperature = Cy_RRAM_GetTemperature(RRAMC0);
  if(CY_RRAM_TEMP_ABOVE_85C_BELOW_100C == temperature)
  {
  //Updated temperature to above 85 degrees celcius and below 100 degrees celcius.
  }
  else
  {
  //Failed to update temperature.
  }
  cy_en_rram_temperature_t
  cy_en_rram_temperature_t
  RRAM Junction Temperature.
  Definition: cy_rram.h:355
  CY_RRAM_TEMP_INVALID
  @ CY_RRAM_TEMP_INVALID
  Invalid/Unknown junction temperature value.
  Definition: cy_rram.h:356
  CY_RRAM_TEMP_ABOVE_85C_BELOW_100C
  @ CY_RRAM_TEMP_ABOVE_85C_BELOW_100C
  85C < Tj <= 100C.
  Definition: cy_rram.h:359
  Cy_RRAM_GetTemperature
  __STATIC_INLINE cy_en_rram_temperature_t Cy_RRAM_GetTemperature(RRAMC_Type *base)
  Get junction temperature.
  Definition: cy_rram.h:1170
  Cy_RRAM_SetTemperature
  __STATIC_INLINE void Cy_RRAM_SetTemperature(RRAMC_Type *base, cy_en_rram_temperature_t temperature)
  Set junction temperature.
  Definition: cy_rram.h:1144

## ◆ Cy_RRAM_GetTemperature()

__STATIC_INLINE cy_en_rram_temperature_t Cy_RRAM_GetTemperature | ( | RRAMC_Type * | base | ) |

Get junction temperature.

Parameters

  base | The pointer to the RRAMC instance.

Returns
  Temperature. Refer cy_en_rram_temperature_t

Function Usage
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Update junction temperature. */
  /* Get the current temperature */
  cy_en_rram_temperature_t temperature = Cy_RRAM_GetTemperature(RRAMC0);
  /* Set temperature to Invalid temperature */
  Cy_RRAM_SetTemperature(base, CY_RRAM_TEMP_INVALID);
  temperature = Cy_RRAM_GetTemperature(RRAMC0);
  if(CY_RRAM_TEMP_INVALID == temperature)
  {
  // Updated to Invalid temperature
  }
  /* SSet temperature to MF */
  Cy_RRAM_SetTemperature(base, CY_RRAM_TEMP_ABOVE_85C_BELOW_100C);
  temperature = Cy_RRAM_GetTemperature(RRAMC0);
  if(CY_RRAM_TEMP_ABOVE_85C_BELOW_100C == temperature)
  {
  //Updated temperature to above 85 degrees celcius and below 100 degrees celcius.
  }
  else
  {
  //Failed to update temperature.
  }

## ◆ Cy_RRAM_SetProtLockableRegion()

cy_en_rram_status_t Cy_RRAM_SetProtLockableRegion | ( | RRAMC_Type * | base,
|  | uint32_t | regionSize
| ) |  |

Sets the size of lockable region in PROTECTED_NVM region.

If size is larger than PROTECTED_NVM, the entire PROTECTED_NVM is lockable. The lockable region can be configured only if the protected nvm lock state is unlocked. The configured region is protected only when the protected nvm lock state is locked

Parameters

  base | The pointer to the RRAMC instance.
  regionSize | Size of lockable region in KB. The valid range is 1-256.

Returns
  Status. Refer cy_en_rram_status_t

Function Usage
  #define NUM_BYTES (0x10)
  RRAMC_Type * base = RRAMC0;
  /* Region size. */
  uint32_t regionSize = 0x64;
  cy_en_rram_status_t status = CY_RRAM_BAD_PARAM;
  uint32_t addr = CY_RRAM_PROTECTED_PROTECTED_S_START_ADDRESS;
  uint8_t writeData[NUM_BYTES];
  for (uint32_t i=0; i<NUM_BYTES; i++)
  {
  writeData[i] = 1;
  }
  /* Update 100KB of PROTECTED_NVM region as lockable. */
  if(Cy_RRAM_GetProtLockState(base) == CY_RRAM_PROTECTED_UNLOCK)
  {
  status = Cy_RRAM_SetProtLockableRegion(base, regionSize);
  }
  if((regionSize -1U) == Cy_RRAM_GetProtLockableRegion(base) && status == CY_RRAM_SUCCESS)
  {
  // Configuration success.
  Cy_RRAM_SetProtLock(base); // Set the lock
  }
  else
  {
  // Configuration fail.
  }
  //Perform write operation on the protected region.
  status = Cy_RRAM_NvmWriteByteArray(base, addr, writeData, NUM_BYTES);
  if(Cy_RRAM_GetAHBError(base) == CY_RRAM_PROTECTED_PRGM_ERROR)
  {
  //Protected program error occurred. Failed to perform write operation on protected region
  }
  else
  {
  // Test case fail.
  }
  CY_RRAM_PROTECTED_UNLOCK
  @ CY_RRAM_PROTECTED_UNLOCK
  Not locked, PARTITION_SIZE_0/1 in PROTECTED_NVM region.
  Definition: cy_rram.h:255
  CY_RRAM_PROTECTED_PRGM_ERROR
  @ CY_RRAM_PROTECTED_PRGM_ERROR
  Programming PROTECTED_NVM lockable subsection.
  Definition: cy_rram.h:329
  CY_RRAM_BAD_PARAM
  @ CY_RRAM_BAD_PARAM
  Bad parameter was passed.
  Definition: cy_rram.h:236
  Cy_RRAM_SetProtLock
  __STATIC_INLINE void Cy_RRAM_SetProtLock(RRAMC_Type *base)
  Enables the lock for the configured PROTECTED_NVM region Cy_RRAM_SetProtLockableRegion().
  Definition: cy_rram.h:1255
  Cy_RRAM_GetProtLockState
  __STATIC_INLINE cy_en_rram_protected_lock_t Cy_RRAM_GetProtLockState(RRAMC_Type *base)
  Get the lock state of the PROTECTED_NVM Lockable region.
  Definition: cy_rram.h:1283
  Cy_RRAM_GetProtLockableRegion
  __STATIC_INLINE uint32_t Cy_RRAM_GetProtLockableRegion(RRAMC_Type *base)
  Gets the size of configured lockable region in PROTECTED_NVM region.
  Definition: cy_rram.h:1227
  Cy_RRAM_SetProtLockableRegion
  cy_en_rram_status_t Cy_RRAM_SetProtLockableRegion(RRAMC_Type *base, uint32_t regionSize)
  Sets the size of lockable region in PROTECTED_NVM region.
  Definition: cy_rram.c:1395

Note
  This API is available for only CM0 secure enclave.

If size is larger than PROTECTED_NVM, the entire PROTECTED_NVM is lockable. The lockable region can be configured only if the protected nvm lock state is unlocked. The configured region is protected only when the protected nvm lock state is locked

## ◆ Cy_RRAM_GetProtLockableRegion()

__STATIC_INLINE uint32_t Cy_RRAM_GetProtLockableRegion | ( | RRAMC_Type * | base | ) |

Gets the size of configured lockable region in PROTECTED_NVM region.

Parameters

  base | The pointer to the RRAMC instance.

Returns
  Size of lockable region in KB.

Function Usage
  #define NUM_BYTES (0x10)
  RRAMC_Type * base = RRAMC0;
  /* Region size. */
  uint32_t regionSize = 0x64;
  cy_en_rram_status_t status = CY_RRAM_BAD_PARAM;
  uint32_t addr = CY_RRAM_PROTECTED_PROTECTED_S_START_ADDRESS;
  uint8_t writeData[NUM_BYTES];
  for (uint32_t i=0; i<NUM_BYTES; i++)
  {
  writeData[i] = 1;
  }
  /* Update 100KB of PROTECTED_NVM region as lockable. */
  if(Cy_RRAM_GetProtLockState(base) == CY_RRAM_PROTECTED_UNLOCK)
  {
  status = Cy_RRAM_SetProtLockableRegion(base, regionSize);
  }
  if((regionSize -1U) == Cy_RRAM_GetProtLockableRegion(base) && status == CY_RRAM_SUCCESS)
  {
  // Configuration success.
  Cy_RRAM_SetProtLock(base); // Set the lock
  }
  else
  {
  // Configuration fail.
  }
  //Perform write operation on the protected region.
  status = Cy_RRAM_NvmWriteByteArray(base, addr, writeData, NUM_BYTES);
  if(Cy_RRAM_GetAHBError(base) == CY_RRAM_PROTECTED_PRGM_ERROR)
  {
  //Protected program error occurred. Failed to perform write operation on protected region
  }
  else
  {
  // Test case fail.
  }

Note
  This API is available for only CM0 secure enclave.

## ◆ Cy_RRAM_SetProtLock()

__STATIC_INLINE void Cy_RRAM_SetProtLock | ( | RRAMC_Type * | base | ) |

Enables the lock for the configured PROTECTED_NVM region Cy_RRAM_SetProtLockableRegion().

Updating the configured region and lockable programming are NOT allowed. The topmost 1KB of lockable region which is always writable regardless of lock status. Once locked, the lock state cannot be changed till next reset.

Parameters

  base | The pointer to the RRAMC instance.

Function Usage
  #define NUM_BYTES (0x10)
  RRAMC_Type * base = RRAMC0;
  /* Region size. */
  uint32_t regionSize = 0x64;
  cy_en_rram_status_t status = CY_RRAM_BAD_PARAM;
  uint32_t addr = CY_RRAM_PROTECTED_PROTECTED_S_START_ADDRESS;
  uint8_t writeData[NUM_BYTES];
  for (uint32_t i=0; i<NUM_BYTES; i++)
  {
  writeData[i] = 1;
  }
  /* Update 100KB of PROTECTED_NVM region as lockable. */
  if(Cy_RRAM_GetProtLockState(base) == CY_RRAM_PROTECTED_UNLOCK)
  {
  status = Cy_RRAM_SetProtLockableRegion(base, regionSize);
  }
  if((regionSize -1U) == Cy_RRAM_GetProtLockableRegion(base) && status == CY_RRAM_SUCCESS)
  {
  // Configuration success.
  Cy_RRAM_SetProtLock(base); // Set the lock
  }
  else
  {
  // Configuration fail.
  }
  //Perform write operation on the protected region.
  status = Cy_RRAM_NvmWriteByteArray(base, addr, writeData, NUM_BYTES);
  if(Cy_RRAM_GetAHBError(base) == CY_RRAM_PROTECTED_PRGM_ERROR)
  {
  //Protected program error occurred. Failed to perform write operation on protected region
  }
  else
  {
  // Test case fail.
  }

Note
  This API is available for only CM0 secure enclave.

## ◆ Cy_RRAM_GetProtLockState()

__STATIC_INLINE cy_en_rram_protected_lock_t Cy_RRAM_GetProtLockState | ( | RRAMC_Type * | base | ) |

Get the lock state of the PROTECTED_NVM Lockable region.

Parameters

  base | The pointer to the RRAMC instance.

Returns
  State. cy_en_rram_protected_lock_t

Function Usage
  #define NUM_BYTES (0x10)
  RRAMC_Type * base = RRAMC0;
  /* Region size. */
  uint32_t regionSize = 0x64;
  cy_en_rram_status_t status = CY_RRAM_BAD_PARAM;
  uint32_t addr = CY_RRAM_PROTECTED_PROTECTED_S_START_ADDRESS;
  uint8_t writeData[NUM_BYTES];
  for (uint32_t i=0; i<NUM_BYTES; i++)
  {
  writeData[i] = 1;
  }
  /* Update 100KB of PROTECTED_NVM region as lockable. */
  if(Cy_RRAM_GetProtLockState(base) == CY_RRAM_PROTECTED_UNLOCK)
  {
  status = Cy_RRAM_SetProtLockableRegion(base, regionSize);
  }
  if((regionSize -1U) == Cy_RRAM_GetProtLockableRegion(base) && status == CY_RRAM_SUCCESS)
  {
  // Configuration success.
  Cy_RRAM_SetProtLock(base); // Set the lock
  }
  else
  {
  // Configuration fail.
  }
  //Perform write operation on the protected region.
  status = Cy_RRAM_NvmWriteByteArray(base, addr, writeData, NUM_BYTES);
  if(Cy_RRAM_GetAHBError(base) == CY_RRAM_PROTECTED_PRGM_ERROR)
  {
  //Protected program error occurred. Failed to perform write operation on protected region
  }
  else
  {
  // Test case fail.
  }

Note
  This API is available for only CM0 secure enclave.

## ◆ Cy_RRAM_SetUDSLock()

__STATIC_INLINE void Cy_RRAM_SetUDSLock | ( | RRAMC_Type * | base | ) |

Enables the lock to avoid access to UDS key.

Once locked, the lock state cannot be changed till next reset.

Parameters

  base | The pointer to the RRAMC instance.

Function Usage
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Set the lock bit. */
  /* Configure UDS to generate AHB error when UDS is locked and read access is done to UDS */
  Cy_RRAM_SetUDSConfig(base, true);
  Cy_RRAM_SetUDSLock(base);
  /* Get status of UDS lock */
  cy_en_rram_uds_lock_t udsLockState = Cy_RRAM_GetUDSLockState(base);
  cy_en_rram_uds_lock_t
  cy_en_rram_uds_lock_t
  RRAM UDS lock for NVM region.
  Definition: cy_rram.h:263
  Cy_RRAM_SetUDSConfig
  __STATIC_INLINE void Cy_RRAM_SetUDSConfig(RRAMC_Type *base, bool config)
  Configure UDS to trigger a AHB error or read as zero without error when there is a read access to UDS...
  Definition: cy_rram.h:1368
  Cy_RRAM_SetUDSLock
  __STATIC_INLINE void Cy_RRAM_SetUDSLock(RRAMC_Type *base)
  Enables the lock to avoid access to UDS key.
  Definition: cy_rram.h:1309
  Cy_RRAM_GetUDSLockState
  __STATIC_INLINE cy_en_rram_uds_lock_t Cy_RRAM_GetUDSLockState(RRAMC_Type *base)
  Get the status of UDS lock.
  Definition: cy_rram.h:1338

Note
  This API is available for only CM0 secure enclave.

## ◆ Cy_RRAM_GetUDSLockState()

__STATIC_INLINE cy_en_rram_uds_lock_t Cy_RRAM_GetUDSLockState | ( | RRAMC_Type * | base | ) |

Get the status of UDS lock.

If it is locked then there will be no access to UDS key. Until the lock is unlocked. The lock state cannot be changed till next reset.

Parameters

  base | The pointer to the RRAMC instance.

Returns
  lockState State of the lock. Refer cy_en_rram_uds_lock_t

Function Usage
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Set the lock bit. */
  /* Configure UDS to generate AHB error when UDS is locked and read access is done to UDS */
  Cy_RRAM_SetUDSConfig(base, true);
  Cy_RRAM_SetUDSLock(base);
  /* Get status of UDS lock */
  cy_en_rram_uds_lock_t udsLockState = Cy_RRAM_GetUDSLockState(base);

Note
  This API is available for only CM0 secure enclave.

## ◆ Cy_RRAM_SetUDSConfig()

__STATIC_INLINE void Cy_RRAM_SetUDSConfig | ( | RRAMC_Type * | base,
|  | bool | config
| ) |  |

Configure UDS to trigger a AHB error or read as zero without error when there is a read access to UDS.

It is effective only when UDS is locked.

Parameters

  base | The pointer to the RRAMC instance.
  config | Set to true to trigger AHB error when there is a read access to UDS. Set to false to return read as zero for the read access without any AHB error.

Function Usage
  RRAMC_Type * base = RRAMC0;
  /* Scenario: Set the lock bit. */
  /* Configure UDS to generate AHB error when UDS is locked and read access is done to UDS */
  Cy_RRAM_SetUDSConfig(base, true);
  Cy_RRAM_SetUDSLock(base);
  /* Get status of UDS lock */
  cy_en_rram_uds_lock_t udsLockState = Cy_RRAM_GetUDSLockState(base);

Note
  This API is available for only CM0 secure enclave.

## ◆ Cy_RRAM_ForceRelPCLock()

__STATIC_INLINE void Cy_RRAM_ForceRelPCLock | ( | RRAMC_Type * | base | ) |

Release PC lock forcefully.

In order to avoid deadlock situation during indirect write operation, CM0 has the capability to release or break the acquired lock. Should be called only when a pc lock acquired by CM33/CM55 during indirect write operation needs be released forcefully. This API can be called before the start of write operation from CM0. This API is only available for CM0 secure enclave.