diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-04-07 21:22:06 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-04-07 21:22:06 +0000 |
commit | 8ca829501528bb3895be055cece3af6a99dac0eb (patch) | |
tree | e64878b53bc93757bcf4a654d1bc919031dd6702 /nuttx/arch/arm/src/stm32/stm32_i2c.c | |
parent | b7527ff1800f938dcadc65ece0abbbe4a69821eb (diff) | |
download | px4-nuttx-8ca829501528bb3895be055cece3af6a99dac0eb.tar.gz px4-nuttx-8ca829501528bb3895be055cece3af6a99dac0eb.tar.bz2 px4-nuttx-8ca829501528bb3895be055cece3af6a99dac0eb.zip |
I2C fixes from Uros; USB serial fix from Sheref; + A little more kernel mode stuff
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3479 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/stm32/stm32_i2c.c')
-rw-r--r-- | nuttx/arch/arm/src/stm32/stm32_i2c.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_i2c.c b/nuttx/arch/arm/src/stm32/stm32_i2c.c index dbbc11d5f..90673ef62 100644 --- a/nuttx/arch/arm/src/stm32/stm32_i2c.c +++ b/nuttx/arch/arm/src/stm32/stm32_i2c.c @@ -221,16 +221,15 @@ static void stm32_i2c_setclock(FAR struct stm32_i2c_priv_s *priv, uint32_t frequ * Duty: t_low / t_high = 1 */ stm32_i2c_putreg(priv, STM32_I2C_CCR_OFFSET, STM32_BOARD_HCLK/200000); - stm32_i2c_putreg(priv, STM32_I2C_TRISE_OFFSET, 1 + STM32_BOARD_HCLK/1000000); + stm32_i2c_putreg(priv, STM32_I2C_TRISE_OFFSET, STM32_BOARD_HCLK/1000000 + 1); } else { /* Speed: 400 kHz - * Risetime: 1000 ns ??? \todo check rise time for 400 kHz devices * Duty: t_low / t_high = 2 */ stm32_i2c_putreg(priv, STM32_I2C_CCR_OFFSET, STM32_BOARD_HCLK/1200000); - stm32_i2c_putreg(priv, STM32_I2C_TRISE_OFFSET, 1 + STM32_BOARD_HCLK/1000000); + stm32_i2c_putreg(priv, STM32_I2C_TRISE_OFFSET, 300*(STM32_BOARD_HCLK / 1000000)/1000 + 1); } /* Restore state */ @@ -594,26 +593,26 @@ int stm32_i2c_process(FAR struct i2c_dev_s *dev, FAR struct i2c_msg_s *msgs, int uint32_t status = 0; int status_errno = 0; - ASSERT(count); + extern void up_waste(void); - /* The semaphore already ensures that I2C is ours, since we do not yet support - * non-blocking operation. + ASSERT(count); + + /* wait as stop might still be in progress + * + * \todo GET RID OF THIS PERFORMANCE LOSS and for() loop */ - + for (; stm32_i2c_getreg(inst->priv, STM32_I2C_CR1_OFFSET) & I2C_CR1_STOP; ) up_waste(); + + /* Old transfers are done */ inst->priv->msgv = msgs; inst->priv->msgc = count; - + + /* Set clock (on change it toggles I2C_CR1_PE !) */ stm32_i2c_setclock(inst->priv, inst->frequency); - - /* Trigger start condition, then the process moves into the ISR, - * waiting again for the samaphore ... the resulting status is - * found in the local status variable. - */ - -// inst->priv->status = 0; -// printf("isr_count = %d\n", isr_count); fflush(stdout); - + + /* Trigger start condition, then the process moves into the ISR */ stm32_i2c_sendstart(inst->priv); + #ifdef NON_ISR do { |