18 releases

0.0.17 Apr 11, 2020
0.0.16 Apr 11, 2020
0.0.5 Mar 31, 2020

#8 in #gba

Download history 6/week @ 2024-03-31 75/week @ 2024-07-07

75 downloads per month

Zlib license

62KB
910 lines

License:Zlib Minimum Rust Version TravisCI crates.io docs.rs

rubidium

GBA Memory-mapped IO (MMIO) types and declarations.


lib.rs:

GBA Memory-mapped IO (MMIO) stuff.

The GBA is controlled via MMIO. An MMIO location is called a "register", similar to the CPU having registers. The different registers are all globally accessible, so user code must have its own convention for who is supposed to touch what values when.

This crate defines newtypes that describe the data layout of each register, and if you enable the unsafe_addresses feature it also defines the addresses of each register. The type of address used for each register lets you know about the safety (or not) of accessing a given register. The safety assessment relies on the code being run only on a GBA, so if you use this crate on your desktop or something that's your fault.

This is only "work in progress" status, but please file an issue if things are unclear. While you're waiting you can also check GBATEK, which is the standard resource for GBA info (and it's most of where this crate's docs come from).

Naming Conventions

By default, the name used for an address is the same as the GBATEK name.

In some cases I've combined what GBATEK considers multiple adjacent registers into a single larger register. For example, WININ and WINOUT have been combined to simply be exposed as WIN_CONTROL. The MMIO is flexible like this, as long as the alignment of the combined address is correct for the combined data type it's all fine. Let me know what you think (tracker), because we could make adjustments in this area.

For each setting within a register data newtype there will be three methods per setting contained within the newtype:

  • A const "getter" named the same as the setting (eg: foo).
  • A const "with-er" which takes self and returns a new value (eg: with_foo).
  • A "setter" which takes &mut self and updates the value in place (eg: set_foo). This will hopefully also be const in a future version of Rust.

No runtime deps

Features