title: Struct pointer to access register on microcontroller?
body: <p>I'm trying to understand the cmsis header file included with the STM-32 Cortex-M4 microcontroller.
  They have a struct that is </p>
  
  <pre><code>typedef struct
  {
    __IO uint32_t MODER;    /*!&lt; GPIO port mode register,               Address offset: 0x00      */
    __IO uint32_t OTYPER;   /*!&lt; GPIO port output type register,        Address offset: 0x04      */
    __IO uint32_t OSPEEDR;  /*!&lt; GPIO port output speed register,       Address offset: 0x08      */
    __IO uint32_t PUPDR;    /*!&lt; GPIO port pull-up/pull-down register,  Address offset: 0x0C      */
    __IO uint32_t IDR;      /*!&lt; GPIO port input data register,         Address offset: 0x10      */
    __IO uint32_t ODR;      /*!&lt; GPIO port output data register,        Address offset: 0x14      */
    __IO uint16_t BSRRL;    /*!&lt; GPIO port bit set/reset low register,  Address offset: 0x18      */
    __IO uint16_t BSRRH;    /*!&lt; GPIO port bit set/reset high register, Address offset: 0x1A      */
    __IO uint32_t LCKR;     /*!&lt; GPIO port configuration lock register, Address offset: 0x1C      */
    __IO uint32_t AFR[2];   /*!&lt; GPIO alternate function registers,     Address offset: 0x20-0x24 */
  } GPIO_TypeDef;
  </code></pre>
  
  <p>Does it make sense, for example, to write:</p>
  
  <pre><code>((GPIO_TypeDef *) 0x08000) -&gt; MODER = 0x12;
  </code></pre>
  
  <p>I don't get what this line is doing.
  It would make more sense to me if you did</p>
  
  <pre><code>GPIO_TypeDef * td = 0x08000;
  td -&gt; MODER = 0x12;
  </code></pre>
  
  <p>Are these the same? Why?</p>