Assembly examples for Red-V Thing Plus (SiFive FE310-G002)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
flabbergast 930b40bef2 Add debugging info into README. 5 months ago
..
Makefile Add 08-i2c. 5 months ago
README.md Add 08-i2c. 5 months ago
macros.s Add 08-i2c. 5 months ago
main.s Add 08-i2c. 5 months ago
memmap Add 08-i2c. 5 months ago
p_clock.s Add 08-i2c. 5 months ago
p_delay.s Add 08-i2c. 5 months ago
p_i2c.s Add 08-i2c. 5 months ago
p_interrupts.s Add 08-i2c. 5 months ago
p_uart0.s Add 08-i2c. 5 months ago
platform_regs.inc Add 08-i2c. 5 months ago
write.s Add 08-i2c. 5 months ago

README.md

08-i2c

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.

Lessons learned

  • 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.inc by hand, re-check at least 17 times.
  • Re-check push/pop patterns, especially when returning early, e.g. from a macro.