fix bug in i2c library where i/o was not set low

you have to write *0* to the clear register to set the port low.
always the weird gotcha on that one...
This commit is contained in:
bunnie 2024-07-05 01:59:14 +08:00
parent 2ebe7f3c64
commit c3bbbbd672
2 changed files with 5 additions and 1 deletions

View file

@ -26,6 +26,8 @@ pub fn hello_world() -> usize {
#[rustfmt::skip]
bio_code!(hello_world_code, HELLO_START, HELLO_END,
"add x1, zero, 0x10",
// "li x2, 0xFFFFFFFF", // set all pins to outputs
// "mv x24, x2",
"0:",
"add x1, x1, 0x1",
"mv x21, x1",

View file

@ -219,7 +219,9 @@ bio_code!(
// setup gpios
"mv x20, x0", // sync to clock stream
"or x26, x4, x5", // set GPIO mask
"or x23, x4, x5", // clear SCL/SDA pins to 0 for "output low"
"or x12, x4, x5", // form bitmask in true sense
"xori x12, x12, -1", // invert because you need to write 0 to set outputs to low
"mv x23, x12", // clear SCL/SDA pins to 0 for "output low"
"or x25, x4, x5", // SCL/SDA to inputs
// setup done
"mv x20, x0", // sync to clock stream