damaki / DW1000

A SPARK/Ada driver for the DecaWave DW1000 Ultra-Wideband tranceiver.
MIT License
13 stars 5 forks source link

Add types for DW1000 register fields. #9

Closed damaki closed 4 years ago

damaki commented 4 years ago

This adds better type definitions for the register fields in the DW1000 register set. Currently, the Bits_xx types are used for the register fields which means the user code must use "magic numbers" to set the fields to the correct value for what the user wants to do. This is not ideal.

These new field types make the code using the DW1000 registers more readable.

For example, the previous code:

SYS_CFG_Reg.RXM110K := 1;

becomes:

SYS_CFG_Reg.RXM110K := SFD_110K;

Additionally, the System_Time types are now used directly in the relevant register types. This avoids needing to perform conversions from Bits_40 to Fine_System_Time or Coarse_System_Time and other time types. Representation clauses for these fixed-point types ('Small and 'Size) ensure that the underlying representation of these types matches the DW1000 register values.