Commit Graph

33 Commits (d8c2c6f97fe419d682cdc11d859a4ce2952ca23d)

Author SHA1 Message Date
int_szyk 5c9daa3941 Tweak stm_spi_api Coverity issue.
Coverity warining: "memset fill truncated (NO_EFFECT)".
Changed SPI_FILL_WORD to SPI_FILL_CHAR.
2019-08-21 16:47:35 +02:00
Vincent Veron 82979f6415 TARGET_STM: SPI: update pull up config depending on clk polarity
Fix #10589

Signed-off-by: Vincent Veron <vincent.veron@st.com>
2019-06-06 17:06:04 +02:00
Vincent Veron 16475829f1 TARGET_STM: SPI: add pulse on master transmissions
Add a pulse when using hardware chip select for SPI transmissions.
CS is at low level when a transmission is on-going.

Be careful, this is not compatible with all modes. It will work only
if PHA is 0, ie spi mode is 0 or 2. See stm32xx reference manual,
chapter "NSS pulse mode" for more details.

Fix #10671

Signed-off-by: Vincent Veron <vincent.veron@st.com>
2019-06-03 10:00:06 +02:00
jeromecoutant 0352bbbd5b STM32 astyle updates 2019-05-10 15:32:05 +02:00
Jarno Lamsa a9f0924f7b Add spi_get_peripheral_name() to stm_spi
This is to have support for per-peripheral mutex introduced in https://github.com/ARMmbed/mbed-os/pull/9469
Together fixes an issue seen in https://github.com/ARMmbed/mbed-os/issues/9149
2019-02-27 13:32:22 +02:00
Russ Butler 8669417e7b Add HAL API for spi pinmap
Add the functions to get spi pinmaps to all targets.
2019-02-08 09:10:37 -06:00
jeromecoutant b1a284a876 STM32: astyle check 2019-01-10 10:22:21 +01:00
Martin Kojtal 63eca294a1
Merge pull request #9163 from InfernoEmbedded/fix-8913-partner
Don't use define checks on DEVICE_FOO macros (partner code)
2019-01-07 16:37:24 +00:00
jeromecoutant 4b67820f8a NUCLEO_H743ZI: add initial SDK 2019-01-04 10:03:36 +01:00
Alastair D'Silva aa80b7c70a Don't use define checks on DEVICE_FOO macros (partner code)
The DEVICE_FOO macros are always defined (either 0 or 1).

This patch replaces any instances of a define check on a DEVICE_FOO
macro with value test instead.

Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
2018-12-20 20:02:29 +11:00
jeromecoutant 433ba46132 TARGET_STM astyle 2018-06-27 14:21:07 +02:00
bcostm 2d7b13c540 STM32 SPI: fix NSS pin configuration 2018-05-18 14:26:26 +02:00
Paul Thompson f41cf081c9 STM32 : correct compilation warnings 2018-04-11 09:53:15 +02:00
jeromecoutant 36c41186a6 STM32 SPI ASYNC - Add FIFO flush before transfer 2018-02-05 11:06:51 +01:00
Laurent MEUNIER 839bd642d0 STM32: SPI 3 wires mode not supported in SPI slave
This patch handles the case of SPI slave mode without MISO (NC).
In case MISO is not connected, we consider that SPI will be configured in
3 wires mode (CLK / MOSI / CS, but no MISO). In this case, the MOSI line
is bi-directional : SPI_DIRECTION_1LINE.

But as this is not supported yet in slave mode, we force it to
SPI_DIRECTION_2LINES. In this case slave SPI will receive data on MOSI
but nothing will be sent back to master as MISO is not connected.
2017-11-23 10:10:05 +01:00
Laurent MEUNIER b01cc966b0 Introduce TIMEOUT_1_BYTE
This makes the code more explicit about what is last parameter of
HAL_SPI_Transmit/HAL_SPI_Receive functions.
2017-09-04 11:16:49 +02:00
mapellil 6dfafc7293 STM32: SPI: Use LL in spi_slave_read
this is more a cosmetic change, but since LL was introduced, we can now
use it here as well.
2017-08-17 11:02:43 +02:00
Laurent MEUNIER 57371ea591 STM32: SPI: Do not enable SPI during Init if 3W
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).
2017-08-17 11:02:43 +02:00
mapellil 4f20cfc0be STM32: SPI: SPI3W / SPI_DIRECTION_1LINE management
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
2017-08-17 11:02:43 +02:00
Deepika 1b797e9081 Closed review comments
1. Doxygen and Grammar related
2. Change dummy to spi_fill
3. Remove NXP driver and add default loop in spi block read (same as all
other drivers)
2017-07-21 09:46:22 -05:00
Laurent MEUNIER 20bd774a6c STM32 SPI specific mode for higher performance
This commit implements a SPI mode which will offer better performance
thanks to usage of Lower Layer API which use fewer registers access,
at the cost of lower robustness (no error management).
2017-06-16 10:23:48 +02:00
Sam Grove e65bb8d1a2 spi: Added default spi_master_block_write implementation to stm targets
There is an easy default implementation of spi_master_block_write that
just calls spi_master_write in a loop, so the default implementation
of spi_master_block_write has been added to all targets.
2017-05-30 23:11:24 -05:00
Martin Kojtal cb3531c438 Merge pull request #4305 from LMESTM/fix_increase_stm32_spi_timeout
Increase stm32 timeout for spi transfers
2017-05-15 16:22:59 +01:00
Laurent MEUNIER 7d17532911 STM32 SPI do not use a timeout for spi transfers
Default timeout of 10ms was reported as an issue in #4300

There seems to be conditions or use cases where the system is loaded with
higher priority tasks so that SPI transfer would be delayed more than 10ms.
Recommendation from MBED team is to not implement any timeout at all as
there is no defined API in MBED to inform application of error cases.
2017-05-12 11:25:47 +02:00
Laurent MEUNIER 675d78d180 STM32 remove usage of deprecated MACROs 2017-05-09 16:48:34 +02:00
Laurent MEUNIER 00bfa3bf4a STM32: change spi error to debug warning
In case the selected frequency is higher than the requested one, it is
better to send a debug warning rather than an blocking error.

In case of such warning, user may need to redefine the clock tree setting
at higher level (reducing peripheral's input clocks during init phase).
2017-02-28 17:00:29 +01:00
Laurent MEUNIER a8f6970a9d STM32: spi_frequency table index fix
In case of prescaler_rank was 0, a -1 index was being used,
which resulted in initialization of the Init.BaudRatePrescaler with
random values.

Now let's better check index and avoid -1 operation, so that prescaler_rank
can be only from 0 to "last_index".
2017-02-13 16:17:33 +01:00
Laurent MEUNIER fd3a3f9de8 STM: SPI: Initialize Rx in spi_master_write
In case Rx is not initiliased its content might be random from stack.
This is causing problem in case of 8 bits read only as the left-side 8 bits
of the returned int value may contain this random byte data. This was for
instance detected when using SDFileSystem Lib.
2017-01-06 13:20:55 +01:00
Laurent MEUNIER e2613d5058 stm32 spi : IRQ handler light optimization
This commit contains a few optimizations to get a better performance
in SPI Asynch mode
2016-11-18 09:59:53 +01:00
Laurent MEUNIER 79af576051 stm32 spi - IRQ management
Disable IRQ when transfer is finished.
Also clear pending IRQ after they have been disabled.
2016-11-18 09:59:53 +01:00
Laurent MEUNIER 446dbe6a0e Clean-up style issues
Fix indentation issues, remove useless comments, correct if/else format
2016-10-13 14:21:02 +02:00
Laurent MEUNIER 661b6adb93 [STM32] spi_master_write - rely on HAL
ASYNCH SPI transfer support has been added based on STM HAL services.
To have both ASYNCH and SYNCH work together, we're also moving the
write API to STM HAL instead of direct registers access.
2016-10-13 14:18:21 +02:00
Laurent MEUNIER 0aeea4950c [STM32] Deploy SPI_ASYNCH to all family
the SPI_ASYNCH feature has been already activated for STM32F4.
This patchset makes it supported on all STM32 families by:
- moving spi_s structure at family level instead of board level
- using the F4 spi_api.c reference implementation and making it a common
stm_spi_api.c file which makes maintenance a lot easier.
- the only part that needs to be implemented for each family is the computation
of the clock frequency input to the spi peripheral which is not the same
accross families. So this is what remains in the spi_api.c of each family.

Because of the introduction of the common file, all the above modifications
needs to be done at once.
2016-10-13 14:18:21 +02:00