mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Merged in jussi_kivilinna/nuttx/stm32l4_i2c_rewrite (pull request #519)
Port STM32F7 I2C driver to STM32L4
* arch/stm32l4: port STM32F7 I2C driver to STM32L4
STM32L4 I2C driver is in work-in-progress state (plentiful of
TODOs and #warnings) and lags many features found in more
up-to-date STM32 I2C drivers. The peripheral on STM32F7 and
STM32L4 are identical except for L4's 'wakeup from stop mode'
flag and STM32F7's I2C driver is in more 'ready to use' state.
Patch ports the STM32F7 I2C driver to STM32L4. The I2C clock
configuration is kept the same as before (I2CCLK = PCLK1 80 Mhz)
instead of switching to STM32F7 arch default that is I2CCLK=HSI.
Further work would be to add configuration option for choosing
I2C clock source instead of current hard-coded default.
* arch/arm/stm32f7: i2c: restore bus frequency after I2C reset
Copy frequency restoration fix from STM32L4 I2C driver to STM32F7 I2C driver.
* arch/arm/stm32f7: i2c: remove unused Kconfig option
* configs/nucleo-l496zg/nsh: enable I2C4 bus with i2ctool
Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
committed by
Gregory Nutt
parent
7a530c404d
commit
bcf4a5d056
@@ -1737,11 +1737,6 @@ config STM32F7_I2CTIMEOTICKS
|
|||||||
default 500
|
default 500
|
||||||
depends on STM32F7_I2C && !STM32F7_I2C_DYNTIMEO
|
depends on STM32F7_I2C && !STM32F7_I2C_DYNTIMEO
|
||||||
|
|
||||||
config STM32F7_I2C_DUTY16_9
|
|
||||||
bool "Frequency with Tlow/Thigh = 16/9 "
|
|
||||||
default n
|
|
||||||
depends on STM32F7_I2C
|
|
||||||
|
|
||||||
endmenu # "I2C Configuration"
|
endmenu # "I2C Configuration"
|
||||||
|
|
||||||
menu "SD/MMC Configuration"
|
menu "SD/MMC Configuration"
|
||||||
|
|||||||
@@ -2522,6 +2522,7 @@ static int stm32_i2c_reset(FAR struct i2c_master_s * dev)
|
|||||||
unsigned int stretch_count;
|
unsigned int stretch_count;
|
||||||
uint32_t scl_gpio;
|
uint32_t scl_gpio;
|
||||||
uint32_t sda_gpio;
|
uint32_t sda_gpio;
|
||||||
|
uint32_t frequency;
|
||||||
int ret = ERROR;
|
int ret = ERROR;
|
||||||
|
|
||||||
ASSERT(dev);
|
ASSERT(dev);
|
||||||
@@ -2538,6 +2539,10 @@ static int stm32_i2c_reset(FAR struct i2c_master_s * dev)
|
|||||||
|
|
||||||
stm32_i2c_sem_wait(dev);
|
stm32_i2c_sem_wait(dev);
|
||||||
|
|
||||||
|
/* Save the current frequency */
|
||||||
|
|
||||||
|
frequency = priv->frequency;
|
||||||
|
|
||||||
/* De-init the port */
|
/* De-init the port */
|
||||||
|
|
||||||
stm32_i2c_deinit(priv);
|
stm32_i2c_deinit(priv);
|
||||||
@@ -2613,6 +2618,10 @@ static int stm32_i2c_reset(FAR struct i2c_master_s * dev)
|
|||||||
/* Re-init the port */
|
/* Re-init the port */
|
||||||
|
|
||||||
stm32_i2c_init(priv);
|
stm32_i2c_init(priv);
|
||||||
|
|
||||||
|
/* Restore the frequency */
|
||||||
|
|
||||||
|
stm32_i2c_setclock(priv, frequency);
|
||||||
ret = OK;
|
ret = OK;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|||||||
@@ -3715,11 +3715,6 @@ config STM32L4_I2CTIMEOTICKS
|
|||||||
default 500
|
default 500
|
||||||
depends on STM32L4_I2C && !STM32L4_I2C_DYNTIMEO
|
depends on STM32L4_I2C && !STM32L4_I2C_DYNTIMEO
|
||||||
|
|
||||||
config STM32L4_I2C_DUTY16_9
|
|
||||||
bool "Frequency with Tlow/Thigh = 16/9 "
|
|
||||||
default n
|
|
||||||
depends on STM32L4_I2C
|
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
menu "SD/MMC Configuration"
|
menu "SD/MMC Configuration"
|
||||||
|
|||||||
+1438
-618
File diff suppressed because it is too large
Load Diff
@@ -95,6 +95,8 @@ CONFIG_STM32L4_TIM1=y
|
|||||||
CONFIG_STM32L4_USART2=y
|
CONFIG_STM32L4_USART2=y
|
||||||
CONFIG_STM32L4_USART3=y
|
CONFIG_STM32L4_USART3=y
|
||||||
CONFIG_SYSTEM_I2CTOOL=y
|
CONFIG_SYSTEM_I2CTOOL=y
|
||||||
|
CONFIG_I2CTOOL_MINBUS=1
|
||||||
|
CONFIG_I2CTOOL_MAXBUS=4
|
||||||
CONFIG_SYSTEM_STACKMONITOR=y
|
CONFIG_SYSTEM_STACKMONITOR=y
|
||||||
CONFIG_SYSTEM_TEE=y
|
CONFIG_SYSTEM_TEE=y
|
||||||
CONFIG_TASK_NAME_SIZE=0
|
CONFIG_TASK_NAME_SIZE=0
|
||||||
|
|||||||
Reference in New Issue
Block a user