STM32F7 and L4 I2cC: Use clock_t for ticks instead of uint32_t to hold system time.

This commit is contained in:
Jussi Kivilinna 2019-01-09 07:28:34 -06:00 committed by Gregory Nutt
parent 47c8e537d1
commit d7f1dc56cf
2 changed files with 30 additions and 30 deletions

View File

@ -398,7 +398,7 @@ struct stm32_trace_s
uint32_t count; /* Interrupt count when status change */
enum stm32_intstate_e event; /* Last event that occurred with this status */
uint32_t parm; /* Parameter associated with the event */
uint32_t time; /* First of event or first status */
clock_t time; /* First of event or first status */
};
/* I2C Device hardware configuration */
@ -440,7 +440,7 @@ struct stm32_i2c_priv_s
#ifdef CONFIG_I2C_TRACE
int tndx; /* Trace array index */
uint32_t start_time; /* Time when the trace was started */
clock_t start_time; /* Time when the trace was started */
/* The actual trace data */
@ -898,9 +898,9 @@ static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv)
#else
static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv)
{
uint32_t timeout;
uint32_t start;
uint32_t elapsed;
clock_t timeout;
clock_t start;
clock_t elapsed;
int ret;
/* Get the timeout value */
@ -936,8 +936,8 @@ static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv)
while (priv->intstate != INTSTATE_DONE && elapsed < timeout);
i2cinfo("intstate: %d elapsed: %d threshold: %d status: 0x%08x\n",
priv->intstate, elapsed, timeout, priv->status);
i2cinfo("intstate: %d elapsed: %ld threshold: %ld status: 0x%08x\n",
priv->intstate, (long)elapsed, (long)timeout, priv->status);
/* Set the interrupt state back to IDLE */
@ -1039,9 +1039,9 @@ stm32_i2c_disable_reload(FAR struct stm32_i2c_priv_s *priv)
static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv)
{
uint32_t start;
uint32_t elapsed;
uint32_t timeout;
clock_t start;
clock_t elapsed;
clock_t timeout;
uint32_t cr;
uint32_t sr;
@ -1244,7 +1244,7 @@ static void stm32_i2c_tracedump(FAR struct stm32_i2c_priv_s *priv)
int i;
syslog(LOG_DEBUG, "Elapsed time: %d\n",
clock_systimer() - priv->start_time);
(int)(clock_systimer() - priv->start_time));
for (i = 0; i < priv->tndx; i++)
{
@ -1252,7 +1252,7 @@ static void stm32_i2c_tracedump(FAR struct stm32_i2c_priv_s *priv)
syslog(LOG_DEBUG,
"%2d. STATUS: %08x COUNT: %3d EVENT: %2d PARM: %08x TIME: %d\n",
i+1, trace->status, trace->count, trace->event, trace->parm,
trace->time - priv->start_time);
(int)(trace->time - priv->start_time));
}
}
#endif /* CONFIG_I2C_TRACE */
@ -2496,14 +2496,14 @@ static int stm32_i2c_process(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s
* wraps up the transfer with a STOP condition.
*/
uint32_t start = clock_systimer();
uint32_t timeout = USEC2TICK(USEC_PER_SEC/priv->frequency) + 1;
clock_t start = clock_systimer();
clock_t timeout = USEC2TICK(USEC_PER_SEC/priv->frequency) + 1;
status = stm32_i2c_getstatus(priv);
while(status & I2C_ISR_BUSY)
while (status & I2C_ISR_BUSY)
{
if((clock_systimer() - start) > timeout)
if ((clock_systimer() - start) > timeout)
{
i2cerr("ERROR: I2C Bus busy");
errval = EBUSY;

View File

@ -397,7 +397,7 @@ struct stm32l4_trace_s
uint32_t count; /* Interrupt count when status change */
enum stm32l4_intstate_e event; /* Last event that occurred with this status */
uint32_t parm; /* Parameter associated with the event */
uint32_t time; /* First of event or first status */
clock_t time; /* First of event or first status */
};
/* I2C Device hardware configuration */
@ -439,7 +439,7 @@ struct stm32l4_i2c_priv_s
#ifdef CONFIG_I2C_TRACE
int tndx; /* Trace array index */
uint32_t start_time; /* Time when the trace was started */
clock_t start_time; /* Time when the trace was started */
/* The actual trace data */
@ -899,9 +899,9 @@ static inline int stm32l4_i2c_sem_waitdone(FAR struct stm32l4_i2c_priv_s *priv)
#else
static inline int stm32l4_i2c_sem_waitdone(FAR struct stm32l4_i2c_priv_s *priv)
{
uint32_t timeout;
uint32_t start;
uint32_t elapsed;
clock_t timeout;
clock_t start;
clock_t elapsed;
int ret;
/* Get the timeout value */
@ -937,8 +937,8 @@ static inline int stm32l4_i2c_sem_waitdone(FAR struct stm32l4_i2c_priv_s *priv)
while (priv->intstate != INTSTATE_DONE && elapsed < timeout);
i2cinfo("intstate: %d elapsed: %d threshold: %d status: 0x%08x\n",
priv->intstate, elapsed, timeout, priv->status);
i2cinfo("intstate: %d elapsed: %ld threshold: %ld status: 0x%08x\n",
priv->intstate, (long)elapsed, (long)timeout, priv->status);
/* Set the interrupt state back to IDLE */
@ -1040,9 +1040,9 @@ stm32l4_i2c_disable_reload(FAR struct stm32l4_i2c_priv_s *priv)
static inline void stm32l4_i2c_sem_waitstop(FAR struct stm32l4_i2c_priv_s *priv)
{
uint32_t start;
uint32_t elapsed;
uint32_t timeout;
clock_t start;
clock_t elapsed;
clock_t timeout;
uint32_t cr;
uint32_t sr;
@ -1245,7 +1245,7 @@ static void stm32l4_i2c_tracedump(FAR struct stm32l4_i2c_priv_s *priv)
int i;
syslog(LOG_DEBUG, "Elapsed time: %d\n",
clock_systimer() - priv->start_time);
(int)(clock_systimer() - priv->start_time));
for (i = 0; i < priv->tndx; i++)
{
@ -1253,7 +1253,7 @@ static void stm32l4_i2c_tracedump(FAR struct stm32l4_i2c_priv_s *priv)
syslog(LOG_DEBUG,
"%2d. STATUS: %08x COUNT: %3d EVENT: %2d PARM: %08x TIME: %d\n",
i+1, trace->status, trace->count, trace->event, trace->parm,
trace->time - priv->start_time);
(int)(trace->time - priv->start_time));
}
}
#endif /* CONFIG_I2C_TRACE */
@ -2646,8 +2646,8 @@ static int stm32l4_i2c_process(FAR struct i2c_master_s *dev,
* wraps up the transfer with a STOP condition.
*/
uint32_t start = clock_systimer();
uint32_t timeout = USEC2TICK(USEC_PER_SEC/priv->frequency) + 1;
clock_t start = clock_systimer();
clock_t timeout = USEC2TICK(USEC_PER_SEC/priv->frequency) + 1;
status = stm32l4_i2c_getstatus(priv);