-
Notifications
You must be signed in to change notification settings - Fork 2.1k
cpu/nrf52: add i2c driver and configs #8318
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
Conversation
91b4ec8
to
3b36409
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks good (except some minors things), I'll test it tomorrow.
cpu/nrf52/periph/i2c.c
Outdated
uint8_t *in_buf = (uint8_t *)data; | ||
assert((bus <= I2C_NUMOF) && (length > 0)); | ||
|
||
DEBUG("[i2c] reading %i byte from the bus\n", length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
byte(s) ?
Same for other DEBUG
function
cpu/nrf52/periph/i2c.c
Outdated
*/ | ||
static mutex_t locks[] = { | ||
MUTEX_INIT, | ||
MUTEX_INIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we initialize all bus locks even if only one is enabled through the periph_conf.h
file ?
@dylad thanks for your review. Please have a look at the latest commits. I've tested this implementation with a srf02 ultrasonic (I2C) sensor and the nrf52dk and the aconno board (acd52832) |
cpu/nrf52/periph/i2c.c
Outdated
(TWIM_SHORTS_LASTRX_STOP_Enabled << TWIM_SHORTS_LASTRX_STOP_Pos); | ||
|
||
/* bus clock speed configuration */ | ||
dev(bus)->FREQUENCY = (TWIM_FREQUENCY_FREQUENCY_K100 << TWIM_FREQUENCY_FREQUENCY_Pos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change TWIM_FREQUENCY_FREQUENCY_K100
to speed
so we can run I2C at 400 kHz.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I completely overlooked this one. Fixed in latest commit
Ok to squash? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I successfully tested this PR with a nrf52dk
board and one ADXL345 (I2C) using tests/driver_adxl345
-> ACK
You may squash if you want.
Maybe we should wait a bit before merging it to see if another reviewer have time to look at it ?
fcf2f39
to
6245b41
Compare
Squashed. Sure we can wait if you want. But basically this PR is the same as #7557 which was open for about four months. |
Let's merge this one :) |
Contribution description
This PR adds a peripheral I2C driver for nrf52 MCUs.
Issues/PRs references
Continuation of #7557