Make a few improvements to the SioSerial struct:
- Have init() return Self. It's more ergonomic to create and initialize
the empty struct in one call.
- Enable FIFO. The GBA has a 4-byte UART FIFO. This makes it less
likely to lose received bytes.
- Derive Clone on SioSerial so it can be split and shared with an
interrupt.
- Derive Debug on SioError so results can be unwrapped.
* Remove cargo-xbuild dev dependency
As of Rust nightly 2020-07-15, we can set the default build target
and build-std feature of cargo instead of relying on cargo-xbuild.
Since the thumbv4-non-agb target is the default for all cargo commands,
change the Rust snippets in Makefile.toml to cross-platform duckscript.
The only uglyness we're left with is running the unit tests. We want to
build and run the tests on the host archetecture. Create three platform
overrides for Mac, Windows, Linux and set flags to override the default
target triple and build-std option.
* remove uneeded attribute
From cargo: "the feature `cfg_target_vendor` has been stable since
1.33.0 and no longer requires an attribute to enable"
* Add Serial and GPIO registers and implement embedded_hal traits
Use VolAddress and phantom_fields to populate the SIOCNT, RCNT, and
SIODATA8 registers. Implement embedded_hal serial traits around an empty
SioSerial struct.
Hide serial read and write traits behind a "serial" feature flag
to make embedded-hal and nb dependencies optional.
* UART echo example
Enable the serial feature for this example. Provide a pinout
diagram to assist people with wiring up a USB to UART adapter.
88: crt0.s removed redundant lines, added comments r=Lokathor a=felixjones
The flags of `cpsr_cf` are left untouched, so `cpsr_c` is used instead.
Line 102 was redundant:
```asm
bic r2, r2, #0x1F
orr r2, r2, #0x1F
```
Now it explicitly switches from incoming IRQ mode to system mode.
The same type of explicit switch is done for system mode to IRQ mode (only clearing bits necessary), however the IRQ mode bits are or'd also just-in-case the user has modified `cpsr_c` in their IRQ handler.
The IRQ disable bit is also set, again, just in-case the user changed it.
Hopefully I've managed to communicate the behaviour in the ASM comments.
Co-authored-by: Felix Jones <felix@felixjones.co.uk>
85: Add __IRQ_HANDLER from hello_magic.rs to setup doc r=Lokathor a=Dhs92
Looks like the docs weren't updated when the example was.
Co-authored-by: Alex <forehand.alex@gmail.com>
84: Remove unnecessary branch instruction in crt0 r=Lokathor a=ketsuban
I noticed a while ago that the BEQ instruction wasn't actually doing anything because I forgot the difference between SUB and SUBS (the latter sets condition flags). Moreover, I don't need a BEQ in the first place since ARM instructions are inherently conditional; it's not a huge deal, but it improves performance for this early code because the pipeline stays nice and full.
Co-authored-by: Thomas Winwood <twwinwood@gmail.com>
82: Remove dependency on gbafix r=Lokathor a=ketsuban
As per #80 this is the minimum you have to do to remove gbafix from the toolchain. I ended up doing this myself so that I could load the ELF binary directly into no$gba and use its excellent debugger.
There's no reason for the "main unit code" to ever change (the `0x96` byte before it is a fixed value) but changing the game title, game code, maker code, device type or software version will necessitate recalculating the complement check, and I didn't feel like working out if I could get the assembler to do that for me.
Co-authored-by: Thomas Winwood <twwinwood@gmail.com>
81: Two small tweaks to crt0.s r=Lokathor a=ketsuban
* The use of r3 in the block which copies the .data section into IWRAM is unnecessary.
* The return label in the IRQ handler doesn't need to be global.
Co-authored-by: Thomas Winwood <twwinwood@gmail.com>
* The use of r3 in the block which copies the .data section into IWRAM is unnecessary.
* The return label in the IRQ handler doesn't need to be global.
74: Update IME to be `u16` sized, avoid newtype_enum r=Lokathor a=Lokathor
newtype_enum makes an enum, but an enum can be UB if it's no a valid bit pattern. We should avoid having registers mapped to enum types.
Co-authored-by: Lokathor <zefria@gmail.com>
The hello_magic example does not depend on the gba crate, but the crt0
now assumes that the symbol for the interrupt handler which is defined
in it will be present, as interrupts ought to be handled in some
manner. If neither the symbol or the crate are added then the linker
will give an error, but if anything in the gba crate is used also then
the symbol will be brought in, so defining it manually also would
cause a duplicate definition error. In the future something like
cortex-m-rt's `exception!` macro could be used to better document how
to define this symbol (all their examples depend on at least one
symbol from their runtime library, so they don't have this problem).