This fix addresses issue #2638 for STM32F1.
The STM32F1 family has a diffeerent register set for pull-up and pull-down
settings.
The same principle to read HW state is applied, as in commit:
[STM32] Fix pull over write to all families
except registers are different.
Also in this patch we make code a bit more linear.
Depending on pin_index, different register and shift index must be used.
Instead of checking this in several place, let's make a check at the
beginning of the function and use local register and shift variables.
This applies the same fix as was done for F4 to solve issue #2638.
The fix applies ell to all other families excpet STM32F1.
Basically, to avoid over-writing the pull-up/-down settings, we read the
current state from HW.
STM32F303ZE was introduced in parallel to the changes which consist in
having family wide definitions like device.h file and a common objects
definition.
This target is updated accordingly now to benefit of SPI definitions.
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.
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.
- Remove waiting for 'BTF' flag in 'i2c_stop()':
When 'i2c_stop()' is called from 'i2c_read()' or 'i2c_write()' flag 'BTF'
has already been cleared (indirectly) by the calling functions and therefore
'i2c_stop()' would mistakenly always run into a timeout.
- Delay clock enabling until pins are configured:
Enabling the I2C bus clock before configuring its pins might in rare
cases lead to HW faults on the bus.
- Move initialization of 'handle->Instance' to function 'i2c_reset()':
As 'i2c_reset()' uses '__HAL_I2C_GET_FLAG(handle, I2C_FLAG_BUSY)' field
'handle->Instance' must have been initialized before doing so. Therefore,
this operation has been anticipated by moving it from function
'i2c_frequency()' to function 'i2c_reset()'.
Supported toolchains initialization steps have been modified to make sure
that mbed_sdk_initi is called _after_ RAM initialization and _before_ C++
objects creation.
since this was done, there is no need to redundant SystemCoreClockUpdates
in the drivers
Various toolchains supported in MBED don't follow the same initialization
steps. This can have impacts on platform behavior.
For STM32, it is needed to call the HAL_Init() _after_ the RAM has been
initialized (sdata from flash / zero initialized data) and _before_ the C++
objects are being created, especially if those objects require support
of tickers for instance.
In GCC, this is easily done because SystemInit is called after the ram
initialisation, so HAL_Init does not need to called from mbed_sdk_init.
this is covered by the changes in mbed_overrides.c files.
This series should solve issue reported here:
STM32 (At least F401) breaks if Tickers are activated in a global object #2115
This function reads the pull mode from HW and can then be used
to avoid over-writing the previously set pull-up / pull-down modes.
This is done following reported issue: #2638