||8 months ago|
|Makefile||8 months ago|
|README.md||8 months ago|
|macros.s||8 months ago|
|main.s||8 months ago|
|memmap||8 months ago|
|p_clock.s||8 months ago|
|p_delay.s||8 months ago|
|p_i2c.s||8 months ago|
|p_interrupts.s||8 months ago|
|p_uart0.s||8 months ago|
|platform_regs.inc||8 months ago|
|write.s||8 months ago|
Add a basic i2c driver. Really only 1 function,
i2c_rw which writes some bytes to the i2c bus, and then reads some bytes from it (either/both phases can be skipped).
The "demo" code in
main.s is for messing around with a 24C02 eeprom (256 bytes, so just 1 byte addressing).
Note: the i2c peripheral remains in the "transfer-in-progress" state if there are no pull-ups on the I2C lines -- which there are none on Red-V Thing Plus, unless you use that solder jumper on the bottom of the board. I suppose it is because the peripheral supports clock stretching, and if there's no pullup on the SCL line, then it may remain low indefinitely, and the i2c peripheral is waiting until it comes up.
- Having a debugger is a godsend; I should not ever try to start learning on a bare chip.
- When I write new registers into
platform_regs.incby hand, re-check at least 17 times.
- Re-check push/pop patterns, especially when returning early, e.g. from a macro.