Commit graph

599 commits

Author SHA1 Message Date
Michael Mogenson 51c870281c
Add Serial and GPIO registers and implement embedded_hal traits (#96)
* 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.
2020-12-26 11:28:07 -07:00
Michael Mogenson b354dca479
Fix address of IF register (#97)
GBATEK has the IF register at address 0x04000202.
2020-12-24 10:10:16 -07:00
Nicola Papale 1696c66b1b
Use RFC 2873 asm syntax (#93)
The new syntax is way safer and more ergonomic. In fact, it renders
obsolete some of the warnings in the docs related to the use of `asm!`.
2020-06-14 01:22:59 -06:00
Lokathor af98b63aa1
Add a pre-link-args-crt entry
Per discussion/findings in https://github.com/rust-console/gba/issues/90
2020-01-22 12:25:20 -07:00
bors[bot] 35e9857dcc
Merge #88
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>
2019-09-19 02:34:12 +00:00
Felix Jones 09a7c73004 crt0.s removed redundant instructions and added more asm comments 2019-09-17 23:25:51 +01:00
bors[bot] 898fbdadd0 Merge #85
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>
2019-07-30 06:47:07 +00:00
Alex 478b0ecb0e
Add __IRQ_HANDLER from hello_magic.rs to setup doc
Looks like the docs weren't updated when the example was.
2019-07-29 23:43:26 -07:00
bors[bot] f66ccba442 Merge #84
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>
2019-06-04 20:56:49 +00:00
Thomas Winwood 4d3a287c6b Remove unnecessary branch instruction in crt0 2019-06-04 21:25:57 +01:00
bors[bot] 038b887235 Merge #82
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>
2019-06-04 06:39:02 +00:00
Thomas Winwood 016d9a577d Remove dependency on gbafix 2019-06-02 13:27:35 +01:00
bors[bot] 738301d47c Merge #81
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>
2019-05-09 15:09:30 +00:00
Thomas Winwood fe1d75efc5
Two small tweaks to crt0.s
* 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.
2019-05-09 15:08:11 +01:00
bors[bot] 7b79d012b4 Merge #76
76: typo fix r=Lokathor a=Lokathor



Co-authored-by: Lokathor <zefria@gmail.com>
2019-03-30 22:54:44 +00:00
Lokathor 9491249089 typo 2019-03-06 19:41:03 -07:00
bors[bot] 629a85ccf5 Merge #74
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>
2019-02-15 05:17:51 +00:00
Lokathor ac031627c8 Update IME to be u16 sized, avoid newtype_enum
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.
2019-02-14 22:11:23 -07:00
bors[bot] eb157e00dc Merge #71
71: Dev merge (testing bors) r=Lokathor a=Lokathor



Co-authored-by: Lokathor <zefria@gmail.com>
2019-02-15 04:44:16 +00:00
Lokathor c1a272edce no approvals! 2019-02-14 21:33:06 -07:00
Lokathor 529d41d57a push push 2019-02-14 21:32:29 -07:00
Lokathor f95281c708 bors setup 2019-02-14 21:30:51 -07:00
Lokathor 98a9eefaf5
Merge pull request #65 from rust-console/lokathor
IO Registers + Bitmap book section
2019-02-14 21:23:28 -07:00
Lokathor 0f031e6435 bitmap video explanation 2019-02-14 21:18:21 -07:00
Lokathor 3b688b907c Get all the code lined up 2019-02-14 19:39:34 -07:00
Lokathor 89b7cc0eaa Merge branch 'dev' into lokathor 2019-02-14 19:17:02 -07:00
Lokathor c2fd673715 cut this 2019-02-14 19:16:33 -07:00
Lokathor 273a8bd676 commit the changes 2019-02-14 19:16:09 -07:00
Lokathor 723711695e
Merge pull request #69 from Ruin0x11/add_irq_handling
Add interrupt request handling mechanism
2019-02-14 18:55:44 -07:00
Ian Pickering d15168068b Add __IRQ_HANDLER symbol to hello_magic example
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).
2019-02-13 18:27:27 -08:00
Ian Pickering 0d654032bb Add module for interrupt request (IRQ) handling 2019-02-13 17:08:57 -08:00
Ian Pickering dc2127b2ce Fix incorrect opcode of VBlankIntrWait BIOS function
It should be `swi 0x05` instead of `swi 0x04`.
2019-02-13 17:06:18 -08:00
Lokathor 120cfc87b2 start of bitmap video article 2019-02-13 01:48:29 -07:00
Lokathor d43c66c0d9 new lib file 2019-02-13 01:47:25 -07:00
Lokathor c360c2dce4 example updates 2019-02-13 01:47:12 -07:00
Lokathor 9e7937b956 tag TODOs in docs 2019-02-13 01:46:47 -07:00
Lokathor 5d89414c13 Update the Mode 3/4/5 abstractions 2019-02-13 01:45:48 -07:00
Lokathor 61218d99f2 Update mGBA usage, stuff it in a macros module 2019-02-13 01:45:23 -07:00
Lokathor 2ca888b572 Fix rustfmt to get things a little more compact 2019-02-12 10:00:16 -07:00
Lokathor e95bcb7ed2 final io-registers notes 2019-02-12 09:50:15 -07:00
Lokathor 2929076e55 jump to 120
Picking this because it makes the `hello_magic.rs` lines all stay on one line.
2019-02-12 09:42:17 -07:00
Lokathor b67bdc80a1 io registers lesson, +cargo fmt with lin length down to 100 2019-02-11 21:59:17 -07:00
Lokathor 5113a5a1f2
Merge pull request #64 from rust-console/lokathor
Lokathor
2019-02-11 13:55:17 -07:00
Lokathor 1094794ef8 no more auto-clippy 2019-02-10 12:54:29 -07:00
Lokathor 298e195d28 hardware memory map! 2019-02-09 16:32:50 -07:00
Lokathor da6ce44345 shouldn't this be pub? 2019-02-09 14:35:48 -07:00
Lokathor 84a4b4b89b Explain this better because even I forgot 2019-02-09 12:50:00 -07:00
Lokathor dfadb5ba9f part of a hardware memory map explanation 2019-02-09 04:56:20 -07:00
Lokathor 2dcf5bfe18 Quick explanation of Volatile
We actually don't need to bore the reader with how fancy it is, they can go read the source of the crate it they want.
2019-02-09 03:52:52 -07:00
Lokathor 7f27d83b6e Start of more book work 2019-02-09 03:25:50 -07:00