mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
i2c: Add compiletime check macro for validating the i2c pins.
Use 0x7 as error value for an invalid I2C SDA/SCL-pin value. The macro `I2CBUS_VALID` checks for this value. When a invalid pin is ues, the compiler errors out with: "machine.c:<line>: error 176: sizeof applied to an incomplete type", Error message is not ideal but at-least points to the right location in the code.
This commit is contained in:
1 parent
b5fe9f217f
commit
19ccc4003d
2 files changed
+15
-9
No files matched your search
@@ -398,7 +398,7 @@ void setup_i2c(void) __banked
|
||||
reg_read_m(RTL837X_PIN_MUX_1);
|
||||
for (uint8_t sfp = 0; sfp < machine.n_sfp; sfp++) {
|
||||
uint8_t i2c = machine.sfp_port[sfp].i2c;
|
||||
uint8_t scl_bus = (i2c >> RTL837X_REG_I2C_SCL_SHIFT) & 0x03;
|
||||
uint8_t scl_bus = (i2c >> RTL837X_REG_I2C_SCL_SHIFT) & 0x07;
|
||||
uint8_t sda_bus = (i2c >> RTL837X_REG_I2C_SDA_SHIFT) & 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) {
|
||||
|
||||
Reference in new issue
Block a user