打印

STM32H7使用函数SCB_InvalidateDCache_by_Addr,SCB_CleanDCache_by_Addr等函数注意事项

[复制链接]
1335|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
第8号打板工|  楼主 | 2018-8-10 11:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
特别注意下面这三个函数的形参addr和dsize:

addr : 操作的地址一定要是32字节对齐的。

dsize :一定要是32字节的整数倍


/**
  rief   D-Cache Invalidate by address
  details Invalidates D-Cache for the given address
  param[in]   addr    address (aligned to 32-byte boundary)
  param[in]   dsize   size of memory block (in number of bytes)
*/
__STATIC_INLINE void SCB_InvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize)
{
  #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
     int32_t op_size = dsize;
    uint32_t op_addr = (uint32_t)addr;
     int32_t linesize = 32;                /* in Cortex-M7 size of cache line is fixed to 8 words (32 bytes) */

    __DSB();

    while (op_size > 0) {
      SCB->DCIMVAC = op_addr;
      op_addr += (uint32_t)linesize;
      op_size -=           linesize;
    }

    __DSB();
    __ISB();
  #endif
}


/**
  rief   D-Cache Clean by address
  details Cleans D-Cache for the given address
  param[in]   addr    address (aligned to 32-byte boundary)
  param[in]   dsize   size of memory block (in number of bytes)
*/
__STATIC_INLINE void SCB_CleanDCache_by_Addr (uint32_t *addr, int32_t dsize)
{
  #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
     int32_t op_size = dsize;
    uint32_t op_addr = (uint32_t) addr;
     int32_t linesize = 32;                /* in Cortex-M7 size of cache line is fixed to 8 words (32 bytes) */

    __DSB();

    while (op_size > 0) {
      SCB->DCCMVAC = op_addr;
      op_addr += (uint32_t)linesize;
      op_size -=           linesize;
    }

    __DSB();
    __ISB();
  #endif
}


/**
  rief   D-Cache Clean and Invalidate by address
  details Cleans and invalidates D_Cache for the given address
  param[in]   addr    address (aligned to 32-byte boundary)
  param[in]   dsize   size of memory block (in number of bytes)
*/
__STATIC_INLINE void SCB_CleanInvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize)
{
  #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
     int32_t op_size = dsize;
    uint32_t op_addr = (uint32_t) addr;
     int32_t linesize = 32;                /* in Cortex-M7 size of cache line is fixed to 8 words (32 bytes) */

    __DSB();

    while (op_size > 0) {
      SCB->DCCIMVAC = op_addr;
      op_addr += (uint32_t)linesize;
      op_size -=           linesize;
    }

    __DSB();
    __ISB();
  #endif
}

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

393

主题

393

帖子

0

粉丝