c - 周边定义

标签 c

有人可以向初学者解释以下结构吗:

typedef struct
{
  __IO uint32_t CTRL;     /**< Control Register               */
  __IO uint32_t CNT;      /**< Counter Value Register         */
  __IO uint32_t COMP0;    /**< Compare Value Register 0       */
  __IO uint32_t COMP1;    /**< Compare Value Register 1       */
  __I uint32_t  IF;       /**< Interrupt Flag Register        */
  __IO uint32_t IFS;      /**< Interrupt Flag Set Register    */
  __IO uint32_t IFC;      /**< Interrupt Flag Clear Register  */
  __IO uint32_t IEN;      /**< Interrupt Enable Register      */
  __IO uint32_t FREEZE;   /**< Freeze Register                */
  __I uint32_t  SYNCBUSY; /**< Synchronization Busy Register  */
} RTC_TypeDef;    


#define RTC_BASE     (0x40080000UL)
#define RTC          ((RTC_TypeDef *) RTC_BASE)    

尤其是最后一行

为什么括号如此不寻常? * 是什么意思?指针还是乘法运算符?

谢谢

最佳答案

Why are the brackets so unusual? What does the * mean? Pointer or multiply operator ?

*这是一个指针而不是乘法运算符。

这个宏并没有什么不寻常的地方。它只是将地址类型转换为 struct RTC_TypeDef 类型

关于c - 周边定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30614648/

相关文章:

c - 我如何编写一个函数来复制一个项目数组,用于复制一些定义数量的项目

c - 在 gcc 中如何计算逻辑表达式 2 > -3

c - 动态列表中的 Malloc 函数

c - 线程进给其他多线程

c - 组织数字直到输入 0 0 0

c++ - C 字符集 - 需要说明

c - libc.so.6 在 Linux 内核中的相关性

c - SDL_net没有收到UDP数据包

c - 将时间修改标记写入文件顶部

c++ - 如何检查用户是否按下了 Edit 控件中的某个键