File tree Expand file tree Collapse file tree 31 files changed +117
-26
lines changed
TARGET_STM32F7/TARGET_DISCO_F746NG Expand file tree Collapse file tree 31 files changed +117
-26
lines changed Original file line number Diff line number Diff line change 117
117
*/
118
118
119
119
/* Select the clock sources (other than HSI) to start with (0=OFF, 1=ON) */
120
- #define USE_PLL_HSE_EXTC (1 ) /* Use external clock */
120
+ #define USE_PLL_HSE_EXTC (0 ) /* Use external clock */
121
121
#define USE_PLL_HSE_XTAL (0) /* Use external xtal */
122
122
123
123
/**
Original file line number Diff line number Diff line change 117
117
*/
118
118
119
119
/* Select the clock sources (other than HSI) to start with (0=OFF, 1=ON) */
120
- #define USE_PLL_HSE_EXTC (1 ) /* Use external clock */
120
+ #define USE_PLL_HSE_EXTC (0 ) /* Use external clock */
121
121
#define USE_PLL_HSE_XTAL (0) /* Use external xtal */
122
122
123
123
/**
Original file line number Diff line number Diff line change 93
93
* Timeout value
94
94
*/
95
95
#if !defined (HSE_STARTUP_TIMEOUT )
96
- #define HSE_STARTUP_TIMEOUT ((uint32_t)500 ) /*!< Time out for HSE start up, in ms */
96
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)200 ) /*!< Time out for HSE start up, in ms */
97
97
#endif /* HSE_STARTUP_TIMEOUT */
98
98
99
99
/**
110
110
* Timeout value
111
111
*/
112
112
#if !defined (HSI_STARTUP_TIMEOUT )
113
- #define HSI_STARTUP_TIMEOUT ((uint32_t)5000 ) /*!< Time out for HSI start up */
113
+ #define HSI_STARTUP_TIMEOUT ((uint32_t)100 ) /*!< Time out for HSI start up */
114
114
#endif /* HSI_STARTUP_TIMEOUT */
115
115
116
116
/**
147
147
#endif /* LSE_VALUE */
148
148
149
149
#if !defined (LSE_STARTUP_TIMEOUT )
150
- #define LSE_STARTUP_TIMEOUT ((uint32_t)500 ) /*!< Time out for LSE start up, in ms */
150
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)100 ) /*!< Time out for LSE start up, in ms */
151
151
#endif /* HSE_STARTUP_TIMEOUT */
152
152
153
153
Original file line number Diff line number Diff line change 99
99
#endif /* HSE_VALUE */
100
100
101
101
#if !defined (HSE_STARTUP_TIMEOUT )
102
- #define HSE_STARTUP_TIMEOUT ((uint32_t)500 ) /*!< Time out for HSE start up, in ms */
102
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)200 ) /*!< Time out for HSE start up, in ms */
103
103
#endif /* HSE_STARTUP_TIMEOUT */
104
104
105
105
/**
121
121
122
122
123
123
#if !defined (LSE_STARTUP_TIMEOUT )
124
- #define LSE_STARTUP_TIMEOUT ((uint32_t)5000 ) /*!< Time out for LSE start up, in ms */
124
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)100 ) /*!< Time out for LSE start up, in ms */
125
125
#endif /* HSE_STARTUP_TIMEOUT */
126
126
127
127
Original file line number Diff line number Diff line change 125
125
*/
126
126
127
127
/* Select the clock sources (other than HSI) to start with (0=OFF, 1=ON) */
128
- #define USE_PLL_HSE_EXTC (1 ) /* Use external clock */
129
- #define USE_PLL_HSE_XTAL (1 ) /* Use external xtal */
128
+ #define USE_PLL_HSE_EXTC (0 ) /* Use external clock */
129
+ #define USE_PLL_HSE_XTAL (0 ) /* Use external xtal */
130
130
131
131
/**
132
132
* @}
Original file line number Diff line number Diff line change 100
100
* Timeout value
101
101
*/
102
102
#if !defined (HSE_STARTUP_TIMEOUT )
103
- #define HSE_STARTUP_TIMEOUT ((uint32_t)500 ) /*!< Time out for HSE start up, in ms */
103
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)200 ) /*!< Time out for HSE start up, in ms */
104
104
#endif /* HSE_STARTUP_TIMEOUT */
105
105
106
106
/**
117
117
* Timeout value
118
118
*/
119
119
#if !defined (HSI_STARTUP_TIMEOUT )
120
- #define HSI_STARTUP_TIMEOUT ((uint32_t)5000 ) /*!< Time out for HSI start up */
120
+ #define HSI_STARTUP_TIMEOUT ((uint32_t)100 ) /*!< Time out for HSI start up */
121
121
#endif /* HSI_STARTUP_TIMEOUT */
122
122
123
123
/**
Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ typedef struct
164
164
* @{
165
165
*/
166
166
/* LSE state change timeout */
167
- #define LSE_TIMEOUT_VALUE ((uint32_t)5000 ) /* 5 s */
167
+ #define LSE_TIMEOUT_VALUE ((uint32_t)100 ) /* 5 s */
168
168
169
169
/* Disable Backup domain write protection state change timeout */
170
170
#define DBP_TIMEOUT_VALUE ((uint32_t)100) /* 100 ms */
Original file line number Diff line number Diff line change 106
106
#endif /* HSE_VALUE */
107
107
108
108
#if !defined (HSE_STARTUP_TIMEOUT )
109
- #define HSE_STARTUP_TIMEOUT ((uint32_t)500 ) /*!< Time out for HSE start up, in ms */
109
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)200 ) /*!< Time out for HSE start up, in ms */
110
110
#endif /* HSE_STARTUP_TIMEOUT */
111
111
112
112
/**
Original file line number Diff line number Diff line change 94
94
#endif /* HSE_VALUE */
95
95
96
96
#if !defined (HSE_STARTUP_TIMEOUT )
97
- #define HSE_STARTUP_TIMEOUT ((uint32_t)50 ) /*!< Time out for HSE start up, in ms */
97
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)200 ) /*!< Time out for HSE start up, in ms */
98
98
#endif /* HSE_STARTUP_TIMEOUT */
99
99
100
100
/**
123
123
124
124
125
125
#if !defined (LSE_STARTUP_TIMEOUT )
126
- #define LSE_STARTUP_TIMEOUT ((uint32_t)5000 ) /*!< Time out for LSE start up, in ms */
126
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)100 ) /*!< Time out for LSE start up, in ms */
127
127
#endif /* HSE_STARTUP_TIMEOUT */
128
128
129
129
Original file line number Diff line number Diff line change 93
93
#endif /* HSE_VALUE */
94
94
95
95
#if !defined (HSE_STARTUP_TIMEOUT )
96
- #define HSE_STARTUP_TIMEOUT ((uint32_t)500 ) /*!< Time out for HSE start up, in ms */
96
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)200 ) /*!< Time out for HSE start up, in ms */
97
97
#endif /* HSE_STARTUP_TIMEOUT */
98
98
99
99
/**
122
122
123
123
124
124
#if !defined (LSE_STARTUP_TIMEOUT )
125
- #define LSE_STARTUP_TIMEOUT ((uint32_t)5000 ) /*!< Time out for LSE start up, in ms */
125
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)100 ) /*!< Time out for LSE start up, in ms */
126
126
#endif /* HSE_STARTUP_TIMEOUT */
127
127
128
128
Original file line number Diff line number Diff line change 93
93
#endif /* HSE_VALUE */
94
94
95
95
#if !defined (HSE_STARTUP_TIMEOUT )
96
- #define HSE_STARTUP_TIMEOUT ((uint32_t)500 ) /*!< Time out for HSE start up, in ms */
96
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)200 ) /*!< Time out for HSE start up, in ms */
97
97
#endif /* HSE_STARTUP_TIMEOUT */
98
98
99
99
/**
122
122
123
123
124
124
#if !defined (LSE_STARTUP_TIMEOUT )
125
- #define LSE_STARTUP_TIMEOUT ((uint32_t)5000 ) /*!< Time out for LSE start up, in ms */
125
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)100 ) /*!< Time out for LSE start up, in ms */
126
126
#endif /* HSE_STARTUP_TIMEOUT */
127
127
128
128
Original file line number Diff line number Diff line change 93
93
#endif /* HSE_VALUE */
94
94
95
95
#if !defined (HSE_STARTUP_TIMEOUT )
96
- #define HSE_STARTUP_TIMEOUT ((uint32_t)500 ) /*!< Time out for HSE start up, in ms */
96
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)200 ) /*!< Time out for HSE start up, in ms */
97
97
#endif /* HSE_STARTUP_TIMEOUT */
98
98
99
99
/**
122
122
123
123
124
124
#if !defined (LSE_STARTUP_TIMEOUT )
125
- #define LSE_STARTUP_TIMEOUT ((uint32_t)5000 ) /*!< Time out for LSE start up, in ms */
125
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)100 ) /*!< Time out for LSE start up, in ms */
126
126
#endif /* HSE_STARTUP_TIMEOUT */
127
127
128
128
Original file line number Diff line number Diff line change 142
142
#endif /* LSE_VALUE */
143
143
144
144
#if !defined (LSE_STARTUP_TIMEOUT )
145
- #define LSE_STARTUP_TIMEOUT ((uint32_t)500 ) /*!< Time out for LSE start up, in ms */
145
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)100 ) /*!< Time out for LSE start up, in ms */
146
146
#endif /* HSE_STARTUP_TIMEOUT */
147
147
148
148
/**
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ typedef struct
159
159
* @{
160
160
*/
161
161
#define RCC_DBP_TIMEOUT_VALUE ((uint32_t)100)
162
- #define RCC_LSE_TIMEOUT_VALUE ((uint32_t)5000 )
162
+ #define RCC_LSE_TIMEOUT_VALUE ((uint32_t)100 )
163
163
/**
164
164
* @}
165
165
*/
Original file line number Diff line number Diff line change @@ -133,6 +133,14 @@ inline int i2c_start(i2c_t *obj) {
133
133
// Clear Acknowledge failure flag
134
134
__HAL_I2C_CLEAR_FLAG (& I2cHandle , I2C_FLAG_AF );
135
135
136
+ // Wait the STOP condition has been previously correctly sent
137
+ timeout = FLAG_TIMEOUT ;
138
+ while ((i2c -> CR2 & I2C_CR2_STOP ) == I2C_CR2_STOP ){
139
+ if ((timeout -- ) == 0 ) {
140
+ return 1 ;
141
+ }
142
+ }
143
+
136
144
// Generate the START condition
137
145
i2c -> CR2 |= I2C_CR2_START ;
138
146
Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ void rtc_init(void) {
45
45
rtc_inited = 1 ;
46
46
47
47
RtcHandle .Instance = RTC ;
48
+
49
+ // Check if RTC is already initialized
50
+ if ((RTC -> ISR & RTC_ISR_INITS ) == RTC_ISR_INITS ) return ;
48
51
49
52
// Enable Power clock
50
53
__PWR_CLK_ENABLE ();
Original file line number Diff line number Diff line change @@ -124,6 +124,15 @@ inline int i2c_start(i2c_t *obj)
124
124
// Clear Acknowledge failure flag
125
125
__HAL_I2C_CLEAR_FLAG (& I2cHandle , I2C_FLAG_AF );
126
126
127
+ // Wait the STOP condition has been previously correctly sent
128
+ // This timeout can be avoid in some specific cases by simply clearing the STOP bit
129
+ timeout = FLAG_TIMEOUT ;
130
+ while ((i2c -> CR1 & I2C_CR1_STOP ) == I2C_CR1_STOP ) {
131
+ if ((timeout -- ) == 0 ) {
132
+ return 1 ;
133
+ }
134
+ }
135
+
127
136
// Generate the START condition
128
137
i2c -> CR1 |= I2C_CR1_START ;
129
138
Original file line number Diff line number Diff line change @@ -195,6 +195,14 @@ inline int i2c_start(i2c_t *obj)
195
195
// Clear Acknowledge failure flag
196
196
__HAL_I2C_CLEAR_FLAG (& I2cHandle , I2C_FLAG_AF );
197
197
198
+ // Wait the STOP condition has been previously correctly sent
199
+ timeout = FLAG_TIMEOUT ;
200
+ while ((i2c -> CR2 & I2C_CR2_STOP ) == I2C_CR2_STOP ){
201
+ if ((timeout -- ) == 0 ) {
202
+ return 1 ;
203
+ }
204
+ }
205
+
198
206
// Generate the START condition
199
207
i2c -> CR2 |= I2C_CR2_START ;
200
208
Original file line number Diff line number Diff line change @@ -46,6 +46,9 @@ void rtc_init(void)
46
46
rtc_inited = 1 ;
47
47
48
48
RtcHandle .Instance = RTC ;
49
+
50
+ // Check if RTC is already initialized
51
+ if ((RTC -> ISR & RTC_ISR_INITS ) == RTC_ISR_INITS ) return ;
49
52
50
53
// Enable Power clock
51
54
__PWR_CLK_ENABLE ();
Original file line number Diff line number Diff line change @@ -151,8 +151,17 @@ inline int i2c_start(i2c_t *obj)
151
151
// Clear Acknowledge failure flag
152
152
__HAL_I2C_CLEAR_FLAG (& I2cHandle , I2C_FLAG_AF );
153
153
154
- // Generate the START condition and remove an eventual pending STOP bit
155
- i2c -> CR1 = ((i2c -> CR1 & ~I2C_CR1_STOP ) | I2C_CR1_START );
154
+ // Wait the STOP condition has been previously correctly sent
155
+ // This timeout can be avoid in some specific cases by simply clearing the STOP bit
156
+ timeout = FLAG_TIMEOUT ;
157
+ while ((i2c -> CR1 & I2C_CR1_STOP ) == I2C_CR1_STOP ) {
158
+ if ((timeout -- ) == 0 ) {
159
+ return 1 ;
160
+ }
161
+ }
162
+
163
+ // Generate the START condition
164
+ i2c -> CR1 |= I2C_CR1_START ;
156
165
157
166
// Wait the START condition has been correctly sent
158
167
timeout = FLAG_TIMEOUT ;
Original file line number Diff line number Diff line change @@ -46,6 +46,9 @@ void rtc_init(void)
46
46
rtc_inited = 1 ;
47
47
48
48
RtcHandle .Instance = RTC ;
49
+
50
+ // Check if RTC is already initialized
51
+ if ((RTC -> ISR & RTC_ISR_INITS ) == RTC_ISR_INITS ) return ;
49
52
50
53
// Enable Power clock
51
54
__PWR_CLK_ENABLE ();
Original file line number Diff line number Diff line change @@ -183,6 +183,14 @@ inline int i2c_start(i2c_t *obj)
183
183
// Clear Acknowledge failure flag
184
184
__HAL_I2C_CLEAR_FLAG (& I2cHandle , I2C_FLAG_AF );
185
185
186
+ // Wait the STOP condition has been previously correctly sent
187
+ timeout = FLAG_TIMEOUT ;
188
+ while ((i2c -> CR2 & I2C_CR2_STOP ) == I2C_CR2_STOP ){
189
+ if ((timeout -- ) == 0 ) {
190
+ return 1 ;
191
+ }
192
+ }
193
+
186
194
// Generate the START condition
187
195
i2c -> CR2 |= I2C_CR2_START ;
188
196
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ void rtc_init(void)
40
40
RCC_OscInitTypeDef RCC_OscInitStruct ;
41
41
uint32_t rtc_freq = 0 ;
42
42
43
- if (RTC -> ISR == 7 ) { // RTC initialization and status register (RTC_ISR), cold start (with no backup domain power) RTC reset value
43
+ 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
44
44
45
45
RtcHandle .Instance = RTC ;
46
46
Original file line number Diff line number Diff line change @@ -54,6 +54,9 @@ void rtc_init(void)
54
54
rtc_inited = 1 ;
55
55
56
56
RtcHandle .Instance = RTC ;
57
+
58
+ // Check if RTC is already initialized
59
+ if ((RTC -> ISR & RTC_ISR_INITS ) == RTC_ISR_INITS ) return ;
57
60
58
61
// Enable Power clock
59
62
__PWR_CLK_ENABLE ();
Original file line number Diff line number Diff line change @@ -46,6 +46,9 @@ void rtc_init(void)
46
46
rtc_inited = 1 ;
47
47
48
48
RtcHandle .Instance = RTC ;
49
+
50
+ // Check if RTC is already initialized
51
+ if ((RTC -> ISR & RTC_ISR_INITS ) == RTC_ISR_INITS ) return ;
49
52
50
53
// Enable Power clock
51
54
__PWR_CLK_ENABLE ();
Original file line number Diff line number Diff line change @@ -46,6 +46,9 @@ void rtc_init(void)
46
46
rtc_inited = 1 ;
47
47
48
48
RtcHandle .Instance = RTC ;
49
+
50
+ // Check if RTC is already initialized
51
+ if ((RTC -> ISR & RTC_ISR_INITS ) == RTC_ISR_INITS ) return ;
49
52
50
53
// Enable Power clock
51
54
__PWR_CLK_ENABLE ();
Original file line number Diff line number Diff line change @@ -152,6 +152,14 @@ inline int i2c_start(i2c_t *obj)
152
152
// Clear Acknowledge failure flag
153
153
__HAL_I2C_CLEAR_FLAG (& I2cHandle , I2C_FLAG_AF );
154
154
155
+ // Wait the STOP condition has been previously correctly sent
156
+ timeout = FLAG_TIMEOUT ;
157
+ while ((i2c -> CR2 & I2C_CR2_STOP ) == I2C_CR2_STOP ){
158
+ if ((timeout -- ) == 0 ) {
159
+ return 1 ;
160
+ }
161
+ }
162
+
155
163
// Generate the START condition
156
164
i2c -> CR2 |= I2C_CR2_START ;
157
165
Original file line number Diff line number Diff line change @@ -124,6 +124,15 @@ inline int i2c_start(i2c_t *obj)
124
124
// Clear Acknowledge failure flag
125
125
__HAL_I2C_CLEAR_FLAG (& I2cHandle , I2C_FLAG_AF );
126
126
127
+ // Wait the STOP condition has been previously correctly sent
128
+ // This timeout can be avoid in some specific cases by simply clearing the STOP bit
129
+ timeout = FLAG_TIMEOUT ;
130
+ while ((i2c -> CR1 & I2C_CR1_STOP ) == I2C_CR1_STOP ) {
131
+ if ((timeout -- ) == 0 ) {
132
+ return 1 ;
133
+ }
134
+ }
135
+
127
136
// Generate the START condition
128
137
i2c -> CR1 |= I2C_CR1_START ;
129
138
Original file line number Diff line number Diff line change @@ -46,6 +46,9 @@ void rtc_init(void)
46
46
rtc_inited = 1 ;
47
47
48
48
RtcHandle .Instance = RTC ;
49
+
50
+ // Check if RTC is already initialized
51
+ if ((RTC -> ISR & RTC_ISR_INITS ) == RTC_ISR_INITS ) return ;
49
52
50
53
// Enable Power clock
51
54
__PWR_CLK_ENABLE ();
You can’t perform that action at this time.
0 commit comments