Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C_4 seemingly broken #608

Open
jgoney opened this issue Jan 30, 2024 · 4 comments
Open

I2C_4 seemingly broken #608

jgoney opened this issue Jan 30, 2024 · 4 comments

Comments

@jgoney
Copy link

jgoney commented Jan 30, 2024

I posted on the forum about this here, but tl;dr is that I can't get I2C_4 to work at all. I have no problems getting I2C_1 to work (on either set of supported pins), but I2C_4 does not work for me on either pin set.

I made a Gist for it here. If anyone could try it out just to sanity check it for me, that would already be a huge help.

Please let me know if you need any additional info or context.

@AndrewCapon
Copy link
Contributor

AndrewCapon commented May 4, 2024

It isn't working here either if it makes you feel any better :)

Here is the test code I am using:

#define TEST_I2C 4
int main(void)
{
	hw.Init();

	I2CHandle i2c;
        I2CHandle::Config i2c_config;

#if TEST_I2C == 4
	i2c_config.periph         = I2CHandle::Config::Peripheral::I2C_4;
	i2c_config.speed          = I2CHandle::Config::Speed::I2C_100KHZ;
	i2c_config.mode           = I2CHandle::Config::Mode::I2C_MASTER;
	i2c_config.pin_config.scl = hw.GetPin(13);
	i2c_config.pin_config.sda = hw.GetPin(14);
	i2c_config.address        = 0x3C;	
#else
	i2c_config.periph         = I2CHandle::Config::Peripheral::I2C_1;
	i2c_config.speed          = I2CHandle::Config::Speed::I2C_100KHZ;
	i2c_config.mode           = I2CHandle::Config::Mode::I2C_MASTER;
	i2c_config.pin_config.scl = hw.GetPin(11);
	i2c_config.pin_config.sda = hw.GetPin(12);
	i2c_config.address        = 0x3C;	
#endif	
	i2c.Init(i2c_config);

	uint8_t data;
	while(1)
		i2c.TransmitBlocking(i2c_config.address, &data, 1, 1000); 

	return 0;
}

@AndrewCapon
Copy link
Contributor

Ok, I think I have fixed it.

line 634 of i2c.cpp in libDaisy should be:

GPIO_InitStruct.Alternate = GPIO_AF6_I2C4;

not

GPIO_InitStruct.Alternate = GPIO_AF4_I2C4;

@AndrewCapon
Copy link
Contributor

AndrewCapon commented May 4, 2024

PR put in:

#628

@jgoney
Copy link
Author

jgoney commented May 4, 2024

@AndrewCapon thanks for taking a look at this! I'll test your your fix as well on Monday. 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants