8000 Merge pull request #2588 from dhalbert/nrf-fix-i2c-speed · pdp7/circuitpython@06b4306 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 06b4306

Browse files
authored
Merge pull request adafruit#2588 from dhalbert/nrf-fix-i2c-speed
nrf: fix i2c frequency setting
2 parents 433671f + b6da2fa commit 06b4306

File tree

1 file changed

+10
-4
lines changed
  • ports/nrf/common-hal/busio

1 file changed

+10
-4
lines changed

ports/nrf/common-hal/busio/I2C.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,17 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t *
137137

138138
nrfx_twim_config_t config = NRFX_TWIM_DEFAULT_CONFIG(scl->number, sda->number);
139139

140-
// change freq. only if it's less than the default 400K
141-
if (frequency < 100000) {
142-
config.frequency = NRF_TWIM_FREQ_100K;
143-
} else if (frequency < 250000) {
140+
#if defined(TWIM_FREQUENCY_FREQUENCY_K1000)
141+
if (frequency >= 1000000) {
142+
config.frequency = NRF_TWIM_FREQ_1000K;
143+
} else
144+
#endif
145+
if (frequency >= 400000) {
146+
config.frequency = NRF_TWIM_FREQ_400K;
147+
} else if (frequency >= 250000) {
144148
config.frequency = NRF_TWIM_FREQ_250K;
149+
} else {
150+
config.frequency = NRF_TWIM_FREQ_100K;
145151
}
146152

147153
self->scl_pin_number = scl->number;

0 commit comments

Comments
 (0)
0