-
Notifications
You must be signed in to change notification settings - Fork 2k
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
drivers/periph/spi: Implement thread safety for all SPI devices #2317
Conversation
@@ -189,12 +199,10 @@ int nrf24l01p_on(nrf24l01p_t *dev) | |||
char read; | |||
int status; | |||
|
|||
gpio_clear(dev->cs); | |||
nrf24l01p_read_reg(dev, REG_CONFIG, &read); | |||
hwtimer_spin(DELAY_CS_TOGGLE_TICKS); |
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.
Are these delays needed, or are they accidental left-overs from a previous refactoring?
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.
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.
@gebart yes these delays are superfluous. Would be nice if you could remove them.
@haukepetersen I added you as author on the affected |
BTW: thanks for doing all this task requiring great diligence! |
Updated according to #2290 (comment) |
560a9ac
to
6b0fda6
Compare
gpio_clear(dev->cs); | ||
hwtimer_spin(DELAY_CS_TOGGLE_TICKS); | ||
status = spi_transfer_regs(dev->spi, CMD_R_RX_PAYLOAD, 0, answer, size); | ||
hwtimer_spin(DELAY_CS_TOGGLE_TICKS); | ||
gpio_set(dev->cs); | ||
hwtimer_spin(DELAY_AFTER_FUNC_TICKS); | ||
/* Release the bus for other threads. */ | ||
spi_release(spi-dev); |
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.
missing ">
"
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.
it must be spi_release(dev->spi);
@gebart: except from the small changes in |
@PeterKietzmann Fixed the typo according to your comment, squash and go? (once Travis is done) Should I leave each individual component as a separate commit as now and only squash the small comment fixes or squash it all into one big commit? |
@gebart I would propose to squash the nrf24l01p-, cc110x- and at86rf231-commits but I'm not sure if it's necessary to keep all the other ones separately. Maybe @LudwigOrtmann ha an idea about that? |
4518a51
to
b7baf85
Compare
I'd prefer to leave it at one commit per cpu, just for history clarity. |
Yep that's what was in my mind too. I was just to stupid to phrase. But still, I think you can squash nrf24l01p-, cc110x- and at86rf231-commits. Would like to hear another opinion, maybe from Ludwig? |
I completely agree with the atomicity of the commits not prefixed 'squash' ;) |
@LudwigOrtmann Require was probably just a typo on my side. I will rewrite the message during squashing. |
b7baf85
to
365e5b9
Compare
Signed-off-by: Joakim Gebart <[email protected]>
Signed-off-by: Joakim Gebart <[email protected]>
Signed-off-by: Joakim Gebart <[email protected]>
Signed-off-by: Joakim Gebart <[email protected]>
Signed-off-by: Joakim Gebart <[email protected]>
Signed-off-by: Joakim Gebart <[email protected]>
Signed-off-by: Joakim Gebart <[email protected]>
Signed-off-by: Joakim Gebart <[email protected]>
This change removes extra gpio_clear(dev->cs) before calling nrf24l01p_read_reg(), nrf24l01p_write_reg(). The GPIO handling is not necessary since nrf24l01p_{read,write}_reg() handle the CS pin internally. Signed-off-by: Joakim Gebart <[email protected]>
The delays were introduced in an attempt to fix "inexplicable timing errors", although the errors were in the SPI bus driver rather than the nrf24l01p driver. See also: - RIOT-OS#1704 - RIOT-OS#2315 Signed-off-by: Joakim Gebart <[email protected]>
Signed-off-by: Joakim Gebart <[email protected]>
365e5b9
to
dfb0d58
Compare
I think the removing of the extra delays in nrf24l01p shall remain as a stand alone commit for easier bisection in any future regressions. @PeterKietzmann ACK if you are fine with the current commit line |
I'm happy. ACK&go |
drivers/periph/spi: Implement thread safety for all SPI devices
This implements #2314 for the SPI drivers. (edit: Except for STM32F4 which is implemented in #2290)
I added the generic implementation of SPI thread safety as proposed by @haukepetersen in #2290 to all CPU
periph/spi
implementations and made all drivers which are currently usingperiph/spi
to acquire/release the bus when necessary.I also found a mistake in the nrf24l01p driver, the CS line was cleared/set twice when turning on/off the device.