mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
I2CBUS: Calculate I2C-settings as compiletime instead at runtime.
We can reduce the i2c-settings to just one byte, and this new const value can directly be used by the I2C-peripheral without additional computation. This saves 1-xdata load and a lot of bit-shifting. I see a codesize savings of +200 bytes.
This commit is contained in:
1 parent
b92fba870c
commit
f65d14f452
5 files changed
+59
-91
No files matched your search
@@ -397,8 +397,9 @@ void setup_i2c(void) __banked
|
||||
// HW Control register, enable I2C depending on PIN configuration
|
||||
reg_read_m(RTL837X_PIN_MUX_1);
|
||||
for (uint8_t sfp = 0; sfp < machine.n_sfp; sfp++) {
|
||||
const uint8_t scl_bus = i2c_bus_from_scl_pin(machine.sfp_port[sfp].i2c.scl);
|
||||
const uint8_t sda_bus = i2c_bus_from_sda_pin(machine.sfp_port[sfp].i2c.sda);
|
||||
uint8_t i2c = machine.sfp_port[sfp].i2c;
|
||||
uint8_t scl_bus = (i2c >> 5) & 0x03;
|
||||
uint8_t sda_bus = (i2c >> 2) & 0x07;
|
||||
print_string("Configuring I2C for SFP idx="); print_byte(sfp); print_string(" SCL="); print_byte(scl_bus); print_string(", SDA="); print_byte(sda_bus); write_char('\n');
|
||||
switch (scl_bus) {
|
||||
case 3:
|
||||
|
||||
Reference in new issue
Block a user