Commit Graph

30 Commits (5bddd881e98101f5c491cccf3367894ecb4e89dd)

Author SHA1 Message Date
Bradley Scott 251459e8aa STM32: Remove i2c_read() and i2c_write() redirects to HAL_I2C_IsDeviceReady()
Some I2C devices require specific zero length read/write sequences which
the HAL_I2C_IsDeviceReady() redirect interferes with.  After Removing
these redirects, it was confirmed that zero length reads and writes
would both still work correctly for detecting presence/absence of an
I2C device on a bus.
2017-07-05 14:02:34 -04:00
Laurent MEUNIER 675d78d180 STM32 remove usage of deprecated MACROs 2017-05-09 16:48:34 +02:00
Bradley Scott 2eb4048bbe STM32: Correct I2C master error handling
If I2C slave support is included, then the I2C error handler would
always reset the I2C address, resulting in incorrectly changing the
I2C state to listen for a controller configured as I2C master.  This
change conditionalizes the address setting to only occur if the
controller was in slave mode when the error occurred.
2017-03-24 10:16:34 -04:00
Christopher Haster aff49d8d1e Renamed files in platform to match source names
critical.h     -> mbed_critical.h
sleep.h        -> mbed_sleep.h
toolchain.h    -> mbed_toolchain.h
rtc_time.h     -> mbed_rtc_time.h
semihost_api.h -> mbed_semihost_api.h
wait_api.h     -> mbed_wait_api.h
2017-02-22 18:17:54 -06:00
Sam Grove b7dce71510 Merge pull request #3665 from LMESTM/dev_stm32_gpio_pins_rework
Dev stm32 gpio pins rework
2017-02-21 10:41:16 -06:00
Laurent MEUNIER 5317ea5bb6 STM32: I2C - pin mode
The default pin mode shall be set as part of the pinamp_pinout, and
as defined in tables of PeripheralPins.c, but this is currently
over-written by a call to pin_mode(pin, PullNone); from
mbed_pinmap_common.c, so we need a set the mode again here, including
OpenDrain config as needed for I2C.
2017-02-16 18:57:34 +01:00
Sam Grove 0e04161356 Merge pull request #3685 from LMESTM/fix_i2c_sw_reset
STM32: I2C: reset state machine
2017-02-07 10:38:53 -06:00
Laurent MEUNIER 57f4df64e5 STM32: I2C: reset state machine
this I2C IP is meant for automatic STOP, based on programmed number
of bytes to be sent or receivede, not a user triggered STOP.
So the state machiine needs to be reset in case we use this I2C mbed
unitary API (start / byte_write / byte_read / stop).
2017-02-03 13:41:52 +01:00
Sam Grove b9449dad7c Merge pull request #3628 from LMESTM/fix_warnings
Fix warnings
2017-02-02 10:50:58 -06:00
bcostm c1f712872d Fix bug in i2c_byte_read function 2017-01-24 16:50:55 +01:00
Laurent MEUNIER 1b94e234e3 STM32: I2C: remove warning
Remove unused variables to avoid warnings.
2017-01-23 17:07:52 +01:00
Anna Bridge 74f192add5 Merge pull request #3567 from LMESTM/dev_stm32_hal_F0_V1.7.0
Dev stm32 F0 v1.7.0
2017-01-13 10:52:49 +00:00
Laurent MEUNIER 0ca04ffb3e STM32: HAL update, use I2C function instead of MACRO
Following HAL update, this is needed to use the I2C API function
rather than previously used MACRO.

An assert would fail at compilation time otherwise.
2017-01-10 16:53:15 +01:00
Laurent MEUNIER 4297e3fd36 STM32: I2C: i2c_byte_read return value in case of error
To make clear that an error is being reported, we shall report -1,
2 being the timeout error for i2c_byte_write only.
2017-01-03 18:06:19 +01:00
Laurent MEUNIER 455c2ecbea STM32: I2C: remove debug code
Few debug lines were to be removed / updated.
Move the printf to DEBUG_PRINTF and return the error when needed.
2017-01-03 10:18:56 +01:00
Laurent MEUNIER 20c9af8bec STM32: I2C unitary functions for IP V2
STM32 supported targets have 2 possible versions of I2C.
This patch makes the start / stop / read and write byte work ok for IP V2.
This was not working before and does not seem to be widely used.
2016-12-21 09:27:52 +01:00
Anna Bridge f2ce7ebb99 Merge pull request #3442 from LMESTM/dev_stm_i2c_f1
Dev stm i2c f1
2016-12-19 17:51:58 +00:00
Laurent MEUNIER 580d96431e STM32 I2C manage STOP specific case
In case the user applicaiton makes a mixed usage of unitary function
(start, stop, byte write & read) with SYNC operation (write and read of
data buffers with start and stop management), we need to reset the
STM32 HAL state as it is by-passed by a direct call to STOP
2016-12-16 08:54:39 +01:00
Laurent MEUNIER 8406a99dc8 STM32 I2C: avoid timeout to be 0
In continuation of previous IsDeviceReady case, let's
add 1 in case length is 0 (even though not recommended)
2016-12-16 08:54:39 +01:00
Laurent MEUNIER 37c94a03f0 STM I2C: manage Is Device Ready case
Some device drivers use a data lenght of 0 to check if device is ready.
STM32 HAL provides a dedicated service for that, so let's use it.
2016-12-16 08:54:39 +01:00
Laurent MEUNIER c0ca0a7e2c STM I2C - move i2c_read in SYNC part
just change the place of code to have i2c_read and i2c_write together
2016-12-16 08:54:39 +01:00
Sam Grove 19acef97ee Merge pull request #3429 from LMESTM/fix_stm_i2c_fix_init
Fix stm i2c fix init
2016-12-15 10:35:13 -06:00
Laurent MEUNIER 57eb4a0d1d STM32 F1: move F1 to I2C common code
Now that F1 HAL has been updated to support required APIs,
the F1 family can also be moved to common code.
2016-12-14 08:36:30 +01:00
Laurent MEUNIER 77e202f064 STM32 I2C: use higher IRQ priority for slave vs. master 2016-12-13 11:59:12 +01:00
Laurent MEUNIER 36a0365d2d STM32 I2C: differentiate HW reset and driver reset
Make a distinct i2c_reset function as defined in MBED HAL api,
from the i2C_hw_reset which simply drives the HW reset signals
2016-12-12 17:33:14 +01:00
Laurent MEUNIER 6cdac88a1c SMT32 I2C: initialize clock before configuring PINs
This is needed especially for F1 family but can apply to all.
2016-12-12 14:52:11 +01:00
Laurent MEUNIER ee9c8acbe4 STM32 I2C: Initialize hz parameter before reset
The hz value is used to compute timeouts,
and timeout are used in reset function, so the parameter needs to be
initialized to its default value before being used.
2016-12-12 14:48:43 +01:00
Laurent MEUNIER 9895bcf130 STM32 I2C: restore slave address in case of reset 2016-12-12 14:44:37 +01:00
Laurent MEUNIER 29b32b84b3 STM32 I2C - 1MHZ frequency is allowed
So make the assert to cover all possible values
Also assert applies only for I2C_IP_VERSION_V2.
Also in case of I2C_IP_VERSION_V1, the HAL makes the proper
checks and can dynamically scale the frequency in case of
intermediate value.
2016-12-01 15:20:11 +01:00
Laurent MEUNIER 3fad50287c [STM32] Make most of the I2C code into a common file
Since most of the code in i2c_api.c is now relying on STM32 HAL, there
is now a possibility to make a common usage of this code accross families.

The IP version definition is introduced per family, to allow a switch of
functionnalities, especially the frequency management which differs.
BTw, we fix the F0 frequency settings at the same time.

F1 is managed for now as an exception as the HAL API for sequential transmit
/receive is not yet available (coming soon)
2016-11-30 08:23:13 +01:00