Tiva I2C: Add I2C options to Kconfig
This commit is contained in:
parent
bf5179d0ac
commit
98d9ceb582
@ -318,6 +318,46 @@ config TIVA_DISABLE_GPIOQ_IRQS
|
|||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
|
if TIVA_I2C
|
||||||
|
|
||||||
|
menu "I2C Configuration"
|
||||||
|
|
||||||
|
config TIVA_I2C_DYNTIMEO
|
||||||
|
bool "Use dynamic timeouts"
|
||||||
|
default n
|
||||||
|
|
||||||
|
if TIVA_I2C_DYNTIMEO
|
||||||
|
|
||||||
|
config TIVA_I2C_DYNTIMEO_USECPERBYTE
|
||||||
|
int "Timeout Microseconds per Byte"
|
||||||
|
default 500
|
||||||
|
|
||||||
|
config TIVA_I2C_DYNTIMEO_STARTSTOP
|
||||||
|
int "Timeout for Start/Stop (Milliseconds)"
|
||||||
|
default 1000
|
||||||
|
|
||||||
|
endif # TIVA_I2C_DYNTIMEO
|
||||||
|
|
||||||
|
config TIVA_I2C_TIMEOSEC
|
||||||
|
int "Timeout seconds"
|
||||||
|
default 0
|
||||||
|
|
||||||
|
if !TIVA_I2C_DYNTIMEO
|
||||||
|
|
||||||
|
config TIVA_I2C_TIMEOMS
|
||||||
|
int "Timeout Milliseconds"
|
||||||
|
default 500
|
||||||
|
depends on !TIVA_I2C_DYNTIMEO
|
||||||
|
|
||||||
|
config TIVA_I2C_TIMEOTICKS
|
||||||
|
int "Timeout for Done and Stop (ticks)"
|
||||||
|
default 500
|
||||||
|
depends on !TIVA_I2C_DYNTIMEO
|
||||||
|
|
||||||
|
endif # !TIVA_I2C_DYNTIMEO
|
||||||
|
endmenu # I2C Configuration
|
||||||
|
endif # TIVA_I2C
|
||||||
|
|
||||||
if TIVA_ETHERNET
|
if TIVA_ETHERNET
|
||||||
menu "Tiva/Stellaris Ethernet Configuration"
|
menu "Tiva/Stellaris Ethernet Configuration"
|
||||||
|
|
||||||
|
@ -85,24 +85,24 @@
|
|||||||
|
|
||||||
/* Interrupt wait timeout in seconds and milliseconds */
|
/* Interrupt wait timeout in seconds and milliseconds */
|
||||||
|
|
||||||
#if !defined(CONFIG_TIVA_I2CTIMEOSEC) && !defined(CONFIG_TIVA_I2CTIMEOMS)
|
#if !defined(CONFIG_TIVA_I2C_TIMEOSEC) && !defined(CONFIG_TIVA_I2C_TIMEOMS)
|
||||||
# define CONFIG_TIVA_I2CTIMEOSEC 0
|
# define CONFIG_TIVA_I2C_TIMEOSEC 0
|
||||||
# define CONFIG_TIVA_I2CTIMEOMS 500 /* Default is 500 milliseconds */
|
# define CONFIG_TIVA_I2C_TIMEOMS 500 /* Default is 500 milliseconds */
|
||||||
#elif !defined(CONFIG_TIVA_I2CTIMEOSEC)
|
#elif !defined(CONFIG_TIVA_I2C_TIMEOSEC)
|
||||||
# define CONFIG_TIVA_I2CTIMEOSEC 0 /* User provided milliseconds */
|
# define CONFIG_TIVA_I2C_TIMEOSEC 0 /* User provided milliseconds */
|
||||||
#elif !defined(CONFIG_TIVA_I2CTIMEOMS)
|
#elif !defined(CONFIG_TIVA_I2C_TIMEOMS)
|
||||||
# define CONFIG_TIVA_I2CTIMEOMS 0 /* User provided seconds */
|
# define CONFIG_TIVA_I2C_TIMEOMS 0 /* User provided seconds */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Interrupt wait time timeout in system timer ticks */
|
/* Interrupt wait time timeout in system timer ticks */
|
||||||
|
|
||||||
#ifndef CONFIG_TIVA_I2CTIMEOTICKS
|
#ifndef CONFIG_TIVA_I2C_TIMEOTICKS
|
||||||
# define CONFIG_TIVA_I2CTIMEOTICKS \
|
# define CONFIG_TIVA_I2C_TIMEOTICKS \
|
||||||
(SEC2TICK(CONFIG_TIVA_I2CTIMEOSEC) + MSEC2TICK(CONFIG_TIVA_I2CTIMEOMS))
|
(SEC2TICK(CONFIG_TIVA_I2C_TIMEOSEC) + MSEC2TICK(CONFIG_TIVA_I2C_TIMEOMS))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_TIVA_I2C_DYNTIMEO_STARTSTOP
|
#ifndef CONFIG_TIVA_I2C_DYNTIMEO_STARTSTOP
|
||||||
# define CONFIG_TIVA_I2C_DYNTIMEO_STARTSTOP TICK2USEC(CONFIG_TIVA_I2CTIMEOTICKS)
|
# define CONFIG_TIVA_I2C_DYNTIMEO_STARTSTOP TICK2USEC(CONFIG_TIVA_I2C_TIMEOTICKS)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Macros to convert a I2C pin to a GPIO output */
|
/* Macros to convert a I2C pin to a GPIO output */
|
||||||
@ -588,8 +588,8 @@ static inline int tiva_i2c_sem_waitdone(struct tiva_i2c_priv_s *priv)
|
|||||||
|
|
||||||
/* Calculate a time in the future */
|
/* Calculate a time in the future */
|
||||||
|
|
||||||
#if CONFIG_TIVA_I2CTIMEOSEC > 0
|
#if CONFIG_TIVA_I2C_TIMEOSEC > 0
|
||||||
abstime.tv_sec += CONFIG_TIVA_I2CTIMEOSEC;
|
abstime.tv_sec += CONFIG_TIVA_I2C_TIMEOSEC;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add a value proportional to the number of bytes in the transfer */
|
/* Add a value proportional to the number of bytes in the transfer */
|
||||||
@ -602,8 +602,8 @@ static inline int tiva_i2c_sem_waitdone(struct tiva_i2c_priv_s *priv)
|
|||||||
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
abstime.tv_nsec -= 1000 * 1000 * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif CONFIG_TIVA_I2CTIMEOMS > 0
|
#elif CONFIG_TIVA_I2C_TIMEOMS > 0
|
||||||
abstime.tv_nsec += CONFIG_TIVA_I2CTIMEOMS * 1000 * 1000;
|
abstime.tv_nsec += CONFIG_TIVA_I2C_TIMEOMS * 1000 * 1000;
|
||||||
if (abstime.tv_nsec > 1000 * 1000 * 1000)
|
if (abstime.tv_nsec > 1000 * 1000 * 1000)
|
||||||
{
|
{
|
||||||
abstime.tv_sec++;
|
abstime.tv_sec++;
|
||||||
@ -654,7 +654,7 @@ static inline int tiva_i2c_sem_waitdone(struct tiva_i2c_priv_s *priv)
|
|||||||
#ifdef CONFIG_TIVA_I2C_DYNTIMEO
|
#ifdef CONFIG_TIVA_I2C_DYNTIMEO
|
||||||
timeout = USEC2TICK(tiva_i2c_tousecs(priv->msgc, priv->msgv));
|
timeout = USEC2TICK(tiva_i2c_tousecs(priv->msgc, priv->msgv));
|
||||||
#else
|
#else
|
||||||
timeout = CONFIG_TIVA_I2CTIMEOTICKS;
|
timeout = CONFIG_TIVA_I2C_TIMEOTICKS;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
/* Signal the interrupt handler that we are waiting. NOTE: Interrupts
|
||||||
|
Loading…
Reference in New Issue
Block a user