Both sides previous revision Previous revision Next revision | Previous revision |
software:c:registries [2016/03/02 09:35] – feur | software:c:registries [2018/01/31 14:39] (current) – [CT Board Registers] ruan |
---|
====== Registry Data Types ====== | ====== Register Data Types ====== |
| |
To access the registries in an easy manner they are mapped to a data structure. \\ | To access the registers in an easy manner they are mapped to a data structure. \\ |
A pointer of this type then points to the registry's physical address. \\ \\ | A pointer of this type then points to the register's physical address. \\ \\ |
| |
* The [[#stm32f429zi_registries|registries of the STM32F429ZI]] are represented with [[#struct|structs]]. | * The [[#stm32f429zi_registries|registers of the STM32F429ZI]] are represented with [[#struct|structs]]. |
* The [[#ct_board_registries|registries of the CT Board]] are represented mostly with a combination of [[#struct|structs]] and [[#union|unions]]. | * The [[#ct_board_registries|registers of the CT Board]] are represented mostly with a combination of [[#struct|structs]] and [[#union|unions]]. |
\\ | \\ |
| |
\\ {{type_union.svg}} \\ \\ | \\ {{type_union.svg}} \\ \\ |
| |
===== STM32F429ZI Registries ===== | ===== STM32F429ZI Registers ===== |
| |
Bellow is the definition of the [[stm32:peripherals:gpio|GPIO]] registry to demonstrate the concept. \\ | Below is the definition of the [[stm32:peripherals:gpio|GPIO]] registers to illustrate the concept. \\ |
| |
<code c>typedef struct { | <code c>typedef struct { |
[1]: Bit reset register. */ | [1]: Bit reset register. */ |
volatile uint32_t LCKR; /**< Port lock register. */ | volatile uint32_t LCKR; /**< Port lock register. */ |
volatile uint32_t AFR[2]; /**< [0]: AF register pin 0..7, | volatile uint32_t AFR[2]; /**< [0]: Alternate Function register pin 0..7, |
[1]: AF register pin 8..15. */ | [1]: Alternate Function register pin 8..15. */ |
} reg_gpio_t; | } reg_gpio_t; |
| |
\\ | \\ |
| |
The GPIO registry is mapped to the data type ''reg_gpio_t''. \\ | The GPIO register is mapped to the data type ''reg_gpio_t''. \\ |
For every GPIO port exists a macro, which is simply a pointer of the type ''reg_gpio_t'' pointing to the registries address. \\ | For every GPIO port exists a macro, which is simply a pointer of the type ''reg_gpio_t'' pointing to the registers address. \\ |
For convenience there is a special operator ''<nowiki>-></nowiki>'' to dereference a struct (or union) pointer: | For convenience there is a special operator ''<nowiki>-></nowiki>'' to dereference a struct (or union) pointer: |
<code c> | <code c> |
\\ | \\ |
| |
===== CT Board Registries ===== | ===== CT Board Registers ===== |
| |
The registries of the STM32F429ZI are mostly for configuration purposes, while the registries of the CT Board are mostly holding some kind of data. The data in the CT Board registries can be accessed using different widths, eg. ''uint32_t'' for all DIP switches or ''uint8_t'' for only S7..0. \\ | The registers of the STM32F429ZI are mostly for configuration purposes, while the registers of the CT Board are mostly holding some kind of data. The data in the CT Board registers can be accessed using different widths, eg. ''uint32_t'' for all DIP switches or ''uint8_t'' for only S7..0. \\ |
| |
\\ {{type_combined.svg}} \\ \\ | \\ {{type_combined.svg}} \\ \\ |
| |
Bellow is the definition of the [[ctboard:peripherals:dipsw|DIPSW]] registry to demonstrate the concept. \\ | Below is the definition of the [[ctboard:peripherals:dipsw|DIPSW]] register to illustrate the concept. \\ |
| |
<code c>typedef union { | <code c>typedef union { |
\\ | \\ |
| |
The CT_DIPSW registry can be accessed using either ''uint8_t'' (byte), ''uint16_t'' (halfword) or ''uint32_t'' (word) pointers: | The CT_DIPSW register can be accessed using either ''uint8_t'' (byte), ''uint16_t'' (halfword) or ''uint32_t'' (word) pointers: |
| |
<code c> | <code c> |