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

Fix I2C4 not working #628

Merged
merged 1 commit into from
Sep 20, 2024
Merged

Conversation

AndrewCapon
Copy link
Contributor

Use GPIO_AF6_I2C4 for alternate function

Copy link

github-actions bot commented May 4, 2024

Test Results

151 tests  ±0   151 ✅ ±0   0s ⏱️ ±0s
 16 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit b1c10b6. ± Comparison against base commit f7727ed.

@beserge
Copy link
Contributor

beserge commented May 9, 2024

Unable to confirm this works. Tested on the daisy field, replaced I2C1 with I2C4, which should work since they share pins, but it stops working. More digging may be needed.

@AndrewCapon
Copy link
Contributor Author

AndrewCapon commented May 9, 2024

I don't think they share pins, is the field different to the seed?

This works here for both i2c1 and i2c4 on the seed:

#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;
}

@beserge
Copy link
Contributor

beserge commented May 9, 2024

Sorry for the back and forth, I was able to retest and confirm this is working. Thanks for your contribution!

@stephenhensley stephenhensley merged commit 3a515be into electro-smith:master Sep 20, 2024
6 checks passed
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

Successfully merging this pull request may close these issues.

3 participants