Skip to content

Dev xxxx xxx fix #1403 #1449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
*/

/* Select the clock sources (other than HSI) to start with (0=OFF, 1=ON) */
#define USE_PLL_HSE_EXTC (1) /* Use external clock */
#define USE_PLL_HSE_EXTC (0) /* Use external clock */
#define USE_PLL_HSE_XTAL (0) /* Use external xtal */

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
*/

/* Select the clock sources (other than HSI) to start with (0=OFF, 1=ON) */
#define USE_PLL_HSE_EXTC (1) /* Use external clock */
#define USE_PLL_HSE_EXTC (0) /* Use external clock */
#define USE_PLL_HSE_XTAL (0) /* Use external xtal */

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
* Timeout value
*/
#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT ((uint32_t)500) /*!< Time out for HSE start up, in ms */
#define HSE_STARTUP_TIMEOUT ((uint32_t)200) /*!< Time out for HSE start up, in ms */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are all these timeouts >99 ms?

#endif /* HSE_STARTUP_TIMEOUT */

/**
Expand All @@ -110,7 +110,7 @@
* Timeout value
*/
#if !defined (HSI_STARTUP_TIMEOUT)
#define HSI_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSI start up */
#define HSI_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for HSI start up */
#endif /* HSI_STARTUP_TIMEOUT */

/**
Expand Down Expand Up @@ -147,7 +147,7 @@
#endif /* LSE_VALUE */

#if !defined (LSE_STARTUP_TIMEOUT)
#define LSE_STARTUP_TIMEOUT ((uint32_t)500) /*!< Time out for LSE start up, in ms */
#define LSE_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for LSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
#endif /* HSE_VALUE */

#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT ((uint32_t)500) /*!< Time out for HSE start up, in ms */
#define HSE_STARTUP_TIMEOUT ((uint32_t)200) /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */

/**
Expand All @@ -121,7 +121,7 @@


#if !defined (LSE_STARTUP_TIMEOUT)
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */
#define LSE_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for LSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@
*/

/* Select the clock sources (other than HSI) to start with (0=OFF, 1=ON) */
#define USE_PLL_HSE_EXTC (1) /* Use external clock */
#define USE_PLL_HSE_XTAL (1) /* Use external xtal */
#define USE_PLL_HSE_EXTC (0) /* Use external clock */
#define USE_PLL_HSE_XTAL (0) /* Use external xtal */

/**
* @}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
* Timeout value
*/
#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT ((uint32_t)500) /*!< Time out for HSE start up, in ms */
#define HSE_STARTUP_TIMEOUT ((uint32_t)200) /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */

/**
Expand All @@ -117,7 +117,7 @@
* Timeout value
*/
#if !defined (HSI_STARTUP_TIMEOUT)
#define HSI_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSI start up */
#define HSI_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for HSI start up */
#endif /* HSI_STARTUP_TIMEOUT */

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ typedef struct
* @{
*/
/* LSE state change timeout */
#define LSE_TIMEOUT_VALUE ((uint32_t)5000) /* 5 s */
#define LSE_TIMEOUT_VALUE ((uint32_t)100) /* 5 s */

/* Disable Backup domain write protection state change timeout */
#define DBP_TIMEOUT_VALUE ((uint32_t)100) /* 100 ms */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
#endif /* HSE_VALUE */

#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT ((uint32_t)500) /*!< Time out for HSE start up, in ms */
#define HSE_STARTUP_TIMEOUT ((uint32_t)200) /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
#endif /* HSE_VALUE */

#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT ((uint32_t)50) /*!< Time out for HSE start up, in ms */
#define HSE_STARTUP_TIMEOUT ((uint32_t)200) /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */

/**
Expand Down Expand Up @@ -123,7 +123,7 @@


#if !defined (LSE_STARTUP_TIMEOUT)
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */
#define LSE_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for LSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
#endif /* HSE_VALUE */

#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT ((uint32_t)500) /*!< Time out for HSE start up, in ms */
#define HSE_STARTUP_TIMEOUT ((uint32_t)200) /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */

/**
Expand Down Expand Up @@ -122,7 +122,7 @@


#if !defined (LSE_STARTUP_TIMEOUT)
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */
#define LSE_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for LSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
#endif /* HSE_VALUE */

#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT ((uint32_t)500) /*!< Time out for HSE start up, in ms */
#define HSE_STARTUP_TIMEOUT ((uint32_t)200) /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */

/**
Expand Down Expand Up @@ -122,7 +122,7 @@


#if !defined (LSE_STARTUP_TIMEOUT)
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */
#define LSE_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for LSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
#endif /* HSE_VALUE */

#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT ((uint32_t)500) /*!< Time out for HSE start up, in ms */
#define HSE_STARTUP_TIMEOUT ((uint32_t)200) /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */

/**
Expand Down Expand Up @@ -122,7 +122,7 @@


#if !defined (LSE_STARTUP_TIMEOUT)
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */
#define LSE_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for LSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
#endif /* LSE_VALUE */

#if !defined (LSE_STARTUP_TIMEOUT)
#define LSE_STARTUP_TIMEOUT ((uint32_t)500) /*!< Time out for LSE start up, in ms */
#define LSE_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for LSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ typedef struct
* @{
*/
#define RCC_DBP_TIMEOUT_VALUE ((uint32_t)100)
#define RCC_LSE_TIMEOUT_VALUE ((uint32_t)5000)
#define RCC_LSE_TIMEOUT_VALUE ((uint32_t)100)
/**
* @}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ inline int i2c_start(i2c_t *obj) {
// Clear Acknowledge failure flag
__HAL_I2C_CLEAR_FLAG(&I2cHandle, I2C_FLAG_AF);

// Wait the STOP condition has been previously correctly sent
timeout = FLAG_TIMEOUT;
while ((i2c->CR2 & I2C_CR2_STOP) == I2C_CR2_STOP){
if ((timeout--) == 0) {
return 1;
}
}

// Generate the START condition
i2c->CR2 |= I2C_CR2_START;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ void rtc_init(void) {
rtc_inited = 1;

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__PWR_CLK_ENABLE();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ inline int i2c_start(i2c_t *obj)
// Clear Acknowledge failure flag
__HAL_I2C_CLEAR_FLAG(&I2cHandle, I2C_FLAG_AF);

// Wait the STOP condition has been previously correctly sent
// This timeout can be avoid in some specific cases by simply clearing the STOP bit
timeout = FLAG_TIMEOUT;
while ((i2c->CR1 & I2C_CR1_STOP) == I2C_CR1_STOP) {
if ((timeout--) == 0) {
return 1;
}
}

// Generate the START condition
i2c->CR1 |= I2C_CR1_START;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ inline int i2c_start(i2c_t *obj)
// Clear Acknowledge failure flag
__HAL_I2C_CLEAR_FLAG(&I2cHandle, I2C_FLAG_AF);

// Wait the STOP condition has been previously correctly sent
timeout = FLAG_TIMEOUT;
while ((i2c->CR2 & I2C_CR2_STOP) == I2C_CR2_STOP){
if ((timeout--) == 0) {
return 1;
}
}

// Generate the START condition
i2c->CR2 |= I2C_CR2_START;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ void rtc_init(void)
rtc_inited = 1;

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__PWR_CLK_ENABLE();
Expand Down
13 changes: 11 additions & 2 deletions libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/i2c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,17 @@ inline int i2c_start(i2c_t *obj)
// Clear Acknowledge failure flag
__HAL_I2C_CLEAR_FLAG(&I2cHandle, I2C_FLAG_AF);

// Generate the START condition and remove an eventual pending STOP bit
i2c->CR1 = ((i2c->CR1 & ~I2C_CR1_STOP) | I2C_CR1_START);
// Wait the STOP condition has been previously correctly sent
// This timeout can be avoid in some specific cases by simply clearing the STOP bit
timeout = FLAG_TIMEOUT;
while ((i2c->CR1 & I2C_CR1_STOP) == I2C_CR1_STOP) {
if ((timeout--) == 0) {
return 1;
}
}

// Generate the START condition
i2c->CR1 |= I2C_CR1_START;

// Wait the START condition has been correctly sent
timeout = FLAG_TIMEOUT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ void rtc_init(void)
rtc_inited = 1;

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__PWR_CLK_ENABLE();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ inline int i2c_start(i2c_t *obj)
// Clear Acknowledge failure flag
__HAL_I2C_CLEAR_FLAG(&I2cHandle, I2C_FLAG_AF);

// Wait the STOP condition has been previously correctly sent
timeout = FLAG_TIMEOUT;
while ((i2c->CR2 & I2C_CR2_STOP) == I2C_CR2_STOP){
if ((timeout--) == 0) {
return 1;
}
}

// Generate the START condition
i2c->CR2 |= I2C_CR2_START;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void rtc_init(void)
RCC_OscInitTypeDef RCC_OscInitStruct;
uint32_t rtc_freq = 0;

if(RTC->ISR == 7) { // RTC initialization and status register (RTC_ISR), cold start (with no backup domain power) RTC reset value
if((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) { // RTC initialization and status register (RTC_ISR), cold start (with no backup domain power) RTC reset value

RtcHandle.Instance = RTC;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ void rtc_init(void)
rtc_inited = 1;

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__PWR_CLK_ENABLE();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ void rtc_init(void)
rtc_inited = 1;

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__PWR_CLK_ENABLE();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ void rtc_init(void)
rtc_inited = 1;

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__PWR_CLK_ENABLE();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ inline int i2c_start(i2c_t *obj)
// Clear Acknowledge failure flag
__HAL_I2C_CLEAR_FLAG(&I2cHandle, I2C_FLAG_AF);

// Wait the STOP condition has been previously correctly sent
timeout = FLAG_TIMEOUT;
while ((i2c->CR2 & I2C_CR2_STOP) == I2C_CR2_STOP){
if ((timeout--) == 0) {
return 1;
}
}

// Generate the START condition
i2c->CR2 |= I2C_CR2_START;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ inline int i2c_start(i2c_t *obj)
// Clear Acknowledge failure flag
__HAL_I2C_CLEAR_FLAG(&I2cHandle, I2C_FLAG_AF);

// Wait the STOP condition has been previously correctly sent
// This timeout can be avoid in some specific cases by simply clearing the STOP bit
timeout = FLAG_TIMEOUT;
while ((i2c->CR1 & I2C_CR1_STOP) == I2C_CR1_STOP) {
if ((timeout--) == 0) {
return 1;
}
}

// Generate the START condition
i2c->CR1 |= I2C_CR1_START;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ void rtc_init(void)
rtc_inited = 1;

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__PWR_CLK_ENABLE();
Expand Down
Loading