Skip to content

Commit 89190fd

Browse files
authored
Merge pull request #3381 from jeromecoutant/PR_ST_F1_ASSERT
STM32F1 : map ST HAL assert into MBED assert
2 parents 1219f88 + 0e404c2 commit 89190fd

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

targets/TARGET_STM/TARGET_STM32F1/device/stm32f1xx_hal_conf.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,8 @@
350350
* If expr is true, it returns no value.
351351
* @retval None
352352
*/
353-
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
354-
/* Exported functions ------------------------------------------------------- */
355-
void assert_failed(uint8_t* file, uint32_t line);
353+
#include "mbed_assert.h"
354+
#define assert_param(expr) MBED_ASSERT(expr)
356355
#else
357356
#define assert_param(expr) ((void)0)
358357
#endif /* USE_FULL_ASSERT */

targets/TARGET_STM/TARGET_STM32F1/gpio_irq_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
304304
mode = STM_MODE_IT_FALLING;
305305
obj->event = EDGE_FALL;
306306
} else { // NONE or RISE
307-
mode = STM_MODE_IT_EVT_RESET;
307+
mode = STM_MODE_INPUT;
308308
obj->event = EDGE_NONE;
309309
}
310310
}
@@ -313,7 +313,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
313313
mode = STM_MODE_IT_RISING;
314314
obj->event = EDGE_RISE;
315315
} else { // NONE or FALL
316-
mode = STM_MODE_IT_EVT_RESET;
316+
mode = STM_MODE_INPUT;
317317
obj->event = EDGE_NONE;
318318
}
319319
}

targets/TARGET_STM/TARGET_STM32F1/pinmap.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void pin_mode(PinName pin, PinMode mode)
191191
// set pull-up => bit=1, set pull-down => bit = 0
192192
if (mode == PullUp) {
193193
gpio->ODR |= (0x01 << (pin_index)); // Set pull-up
194-
} else{
194+
} else {
195195
gpio->ODR &= ~(0x01 << (pin_index)); // Set pull-down
196196
}
197197
break;
@@ -209,7 +209,8 @@ void pin_mode(PinName pin, PinMode mode)
209209
/* Internal function for setting the gpiomode/function
210210
* without changing Pull mode
211211
*/
212-
void pin_function_gpiomode(PinName pin, uint32_t gpiomode) {
212+
void pin_function_gpiomode(PinName pin, uint32_t gpiomode)
213+
{
213214

214215
/* Read current pull state from HW to avoid over-write*/
215216
uint32_t port_index = STM_PORT(pin);
@@ -228,13 +229,14 @@ void pin_function_gpiomode(PinName pin, uint32_t gpiomode) {
228229
}
229230

230231
/* Check if pull/pull down is active */
231-
if ((!(*gpio_reg_hl & (0x03 << shift))) // input
232-
&& (!!(*gpio_reg_hl & (0x08 << shift))) // pull-up / down
233-
&& (!(*gpio_reg_hl & (0x04 << shift)))) { // GPIOx_CRL.CNFx.bit0 = 0
234-
if (!!(gpio->ODR & (0x01 << pin_index))) {
235-
pull = PullUp;
236-
} else {
237-
pull = PullDown;
232+
if (!(*gpio_reg_hl & (0x03 << shift))) {// input
233+
if((!!(*gpio_reg_hl & (0x08 << shift))) // pull-up / down
234+
&& (!(*gpio_reg_hl & (0x04 << shift)))) { // GPIOx_CRL.CNFx.bit0 = 0
235+
if (!!(gpio->ODR & (0x01 << pin_index))) {
236+
pull = PullUp;
237+
} else {
238+
pull = PullDown;
239+
}
238240
}
239241
} else { //output
240242
if (!!(*gpio_reg_hl & (0x04 << shift))) { //open drain

targets/TARGET_STM/TARGET_STM32F1/rtc_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ time_t rtc_read(void)
159159
timeinfo.tm_wday = dateStruct.WeekDay;
160160
timeinfo.tm_mon = dateStruct.Month - 1;
161161
timeinfo.tm_mday = dateStruct.Date;
162-
timeinfo.tm_year = dateStruct.Year;
162+
timeinfo.tm_year = dateStruct.Year + 68;
163163
timeinfo.tm_hour = timeStruct.Hours;
164164
timeinfo.tm_min = timeStruct.Minutes;
165165
timeinfo.tm_sec = timeStruct.Seconds;
@@ -186,7 +186,7 @@ void rtc_write(time_t t)
186186
dateStruct.WeekDay = timeinfo->tm_wday;
187187
dateStruct.Month = timeinfo->tm_mon + 1;
188188
dateStruct.Date = timeinfo->tm_mday;
189-
dateStruct.Year = timeinfo->tm_year;
189+
dateStruct.Year = timeinfo->tm_year - 68;
190190
timeStruct.Hours = timeinfo->tm_hour;
191191
timeStruct.Minutes = timeinfo->tm_min;
192192
timeStruct.Seconds = timeinfo->tm_sec;

0 commit comments

Comments
 (0)