-
Notifications
You must be signed in to change notification settings - Fork 3k
Stm32 spi 3 wires mode support #4975
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
In case MISO is not passed at SPI init, then we consider a 3 wires SPI configuration is requested, which corresponds to SPI_DIRECTION_1LINE configuration parameter in STM32 HAL layer. We're then handling this specific case of SPI_DIRECTION_1LINE, in spi_master_write or spi_master_block_write, we call to HAL API
Enabling SPI causes the clock to be output by default. Most devices will not care about extra clock cycles, especially as long as chip select is not active, nevertheless this may cause side issues with other devices especially during init phase. This was actually the case with a 3 wire device (LPS22HB sensor).
this is more a cosmetic change, but since LL was introduced, we can now use it here as well.
in case of 1LINE direction
} else { | ||
return (int)spi->DR; | ||
return LL_SPI_ReceiveData8(SPI_INST(obj)); |
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.
Looking at the LL function, I am not sure that the 8bit data reading will work...
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.
as discussed, this LL function has been verified and tested fine
@0xc0170 thx |
Not yet public? access denied for me |
Hello, sorry but not yet published as this is a temporary version having a dependency with #4975 not yet merged.
regards
From: Martin Kojtal [mailto:[email protected]]
Sent: 31 August, 2017 2:42 PM
To: ARMmbed/mbed-os <[email protected]>
Cc: Licio MAPELLI <[email protected]>; Mention <[email protected]>
Subject: Re: [ARMmbed/mbed-os] Stm32 spi 3 wires mode support (#4975)
https://developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_IKS01A2_SPI3W/
Not yet public? access denied for me
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#4975 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AQzW5gygcEc06Lixh6YHCRWYEeeckHTwks5sdqodgaJpZM4PCrmV>.
|
Anyway, I made it public now in case to want to have a look. |
@0xc0170 @nikapov-ST @mapellil |
@LMESTM no worries :-) |
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
targets/TARGET_STM/stm_spi_api.c
Outdated
} else { | ||
/* In case of 1 WIRE only, first handle TX, then Rx */ | ||
if (tx_length != 0) { | ||
if (HAL_OK != HAL_SPI_Transmit(handle, (uint8_t*)tx_buffer, tx_length, tx_length*10)) { |
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.
tx_length*10
why is it multiplied here and also for rx ? If buffer contains 5 characters, will this send 50?
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.
The last parameter is a timeout: more characters = longer timeout
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.
OK, it might be more clear to create a separate variable that would indicate this (`xxx timeout =length * 10), and explain why the timeout is 10 (in case it fails in future we will know how *10 was chosen).
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.
Ok - I pushed 1 commit with #define to make parameter more explicit.
This makes the code more explicit about what is last parameter of HAL_SPI_Transmit/HAL_SPI_Receive functions.
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
Description
This PR contains the required changes for supporting SPI 3-wires mode communication.
This allows to save 1 pin in constrained PCB designs.
Status
READY
Tests
This mode has been validated by using a ST Sensor by @mapellil @nikapov-ST
The SPI standard mode has been tested with tests-api-spi of ci-test-shield suite and has not shown any regression on any of all STM32 target families.