Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for sub-indices #9

Closed
hannobraun opened this issue Aug 30, 2018 · 2 comments
Closed

Add support for sub-indices #9

hannobraun opened this issue Aug 30, 2018 · 2 comments
Labels
type: enhancement New feature or request

Comments

@hannobraun
Copy link
Contributor

The DW1000 register interface allows for addressing within a register by using a sub-index. This can be required for accessing larger registers, especially since the nRF52832's[1] SPIM peripheral is somewhat restricted in the buffer sizes it supports (also see jamesmunns/nrf52-hal#14).

[1] The nRF52832 is especially relevant to this crate, as it's the microcontroller used on the DWM1001 board.

@hannobraun hannobraun added the type: enhancement New feature or request label Aug 30, 2018
@hannobraun
Copy link
Contributor Author

There's one open question when it comes to implementing support for sub-indices: When accessing only a part of a register, what happens to the getter/setter methods that are generated as part of the R/W types for each register?

Here's a wild idea I just had:

  • Add two type parameters to the generated R/W types that indicate which part of the register is being accessed. They default to 0 and the length of the register (in bytes), but can be set to define any subset of the register.
  • Each getter/setter is only implemented, if the range defined by the two type parameters includes all the bytes that contain the field (using a where clause on the impl block).

I think right now this is mostly science fiction, but it should be possible once we get const generics. Maybe it's even possible to get something like this using typenum.

@hannobraun
Copy link
Contributor Author

I'm closing this issue. Support for sub-registers has been added in #22. A more generic mechanism, as described here, seems unnecessary, as most registers are only a few bytes long, and I don't think the additional complexity is worth it to save a few bytes in an SPI transaction.

The only exceptions that I can think of are RX_BUFFER/TX_BUFFER, and there's a dedicated issue for those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant