CACHE HAL

group nrf_cache_hal

The hardware access layer for managing the CACHE peripheral.

Enums

enum nrf_cache_region_t

Cache regions.

Values:

enumerator NRF_CACHE_REGION_FLASH

Cache region related to Flash access.

enumerator NRF_CACHE_REGION_XIP

Cache region related to XIP access.

Functions

NRF_STATIC_INLINE void nrf_cache_enable(NRF_CACHE_Type *p_reg)

Function for enabling the CACHE peripheral.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE void nrf_cache_disable(NRF_CACHE_Type *p_reg)

Function for disabling the CACHE peripheral.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE void nrf_cache_invalidate(NRF_CACHE_Type *p_reg)

Function for invalidating the cache content.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE void nrf_cache_erase(NRF_CACHE_Type *p_reg)

Function for erasing the cache content.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE bool nrf_cache_erase_status_check(NRF_CACHE_Type const *p_reg)

Function for checking the status of nrf_cache_erase().

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Return values
  • true – Erase is finished.

  • false – Erase is not complete or has not started.

NRF_STATIC_INLINE void nrf_cache_erase_status_clear(NRF_CACHE_Type *p_reg)

Function for clearing the status of the cache erase.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE void nrf_cache_profiling_set(NRF_CACHE_Type *p_reg, bool enable)

Function for setting the cache profiling.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • enable[in] True if cache profiling is to be enabled, false otherwise.

NRF_STATIC_INLINE void nrf_cache_profiling_counters_clear(NRF_CACHE_Type *p_reg)

Function for clearing the cache profiling counters.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE uint32_t nrf_cache_instruction_hit_counter_get(NRF_CACHE_Type const *p_reg, nrf_cache_region_t region)

Function for getting the number of cache hits for instruction fetch from the specified cache region.

Note

Separate counters are used for flash region and XIP region.

Note

Cache profiling must be enabled first. See nrf_cache_profiling_set.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • region[in] Cache region.

Returns

Number of instruction fetch cache hits.

NRF_STATIC_INLINE uint32_t nrf_cache_instruction_miss_counter_get(NRF_CACHE_Type const *p_reg, nrf_cache_region_t region)

Function for getting the number of cache misses for instruction fetch from the specified cache region.

Note

Separate counters are used for flash region and XIP region.

Note

Cache profiling must be enabled first. See nrf_cache_profiling_set.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • region[in] Cache region.

Returns

Number of instruction fetch cache misses.

NRF_STATIC_INLINE uint32_t nrf_cache_data_hit_counter_get(NRF_CACHE_Type const *p_reg, nrf_cache_region_t region)

Function for getting the number of cache hits for data fetch from the specified cache region.

Note

Separate counters are used for flash region and XIP region.

Note

Cache profiling must be enabled first. See nrf_cache_profiling_set.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • region[in] Cache region.

Returns

Number of data fetch cache hits.

NRF_STATIC_INLINE uint32_t nrf_cache_data_miss_counter_get(NRF_CACHE_Type const *p_reg, nrf_cache_region_t region)

Function for getting the number of cache misses for data fetch from the specified cache region.

Note

Separate counters are used for flash region and XIP region.

Note

Cache profiling must be enabled first. See nrf_cache_profiling_set.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • region[in] Cache region.

Returns

Number of data fetch cache misses.

NRF_STATIC_INLINE void nrf_cache_ram_mode_set(NRF_CACHE_Type *p_reg, bool enable)

Function for setting the cache RAM mode.

When configured in the RAM mode, the accesses to internal or external flash will not be cached. In this mode, the cache data contents can be used as the read/write RAM. Only the data content of the cache is available as RAM.

Note

-Enabling the RAM mode causes the RAM to be cleared.

Note

-Disabling the RAM mode causes the cache to be invalidated.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • enable[in] True if the cache RAM mode is to be enabled, false otherwise.

NRF_STATIC_INLINE void nrf_cache_read_lock_enable(NRF_CACHE_Type *p_reg)

Function for blocking the cache content access.

To unlock the cache content access, a reset has to be performed.

Note

Blocking is ignored in the RAM mode.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE void nrf_cache_update_lock_set(NRF_CACHE_Type *p_reg, bool enable)

Function for blocking the cache content updates.

Blocking of updates prevents updating of cache content on cache misses, but the peripheral will continue to check for instruction/data fetches in the content already present in the cache.

Note

Blocking is ignored in the RAM mode.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • enable[in] True if cache content update lock is to be enabled, false otherwise.

NRF_STATIC_INLINE uint32_t nrf_cache_data_get(NRF_CACHEDATA_Type const *p_reg, uint32_t set, uint8_t way, uint8_t word)

Function for getting the cache data word.

Note

When operating in the RAM mode, the cache data is accessible as a general purpose RAM.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • set[in] Set that contains the data to get.

  • way[in] Way that contains the data to get.

  • word[in] Data word index to get.

Returns

32-bit data word.

NRF_STATIC_INLINE uint32_t nrf_cache_tag_get(NRF_CACHEINFO_Type const *p_reg, uint32_t set, uint8_t way)

Function for getting the tag associated with the specified set and way.

The tag is used to check if an entry in the cache matches the address that is being fetched.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • set[in] Set that contains the tag to get.

  • way[in] Way that contains the tag to get.

Returns

Tag value.

NRF_STATIC_INLINE bool nrf_cache_line_validity_check(NRF_CACHEINFO_Type const *p_reg, uint32_t set, uint8_t way)

Function for checking the validity of a cache line associated with the specified set and way.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • set[in] Set that contains the cache line to check.

  • way[in] Way that contains the cache line to check.

Return values
  • true – Cache line is valid.

  • false – Cache line is invalid.

NRF_STATIC_INLINE uint8_t nrf_cache_mru_get(NRF_CACHEINFO_Type const *p_reg, uint32_t set)

Function for getting the most recently used way in the specified set.

The most recently used way is updated on each fetch from the cache and is used for the cache replacement policy.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • set[in] Specified set.

Returns

The most recently used way in the specified set.