Skip to content

STM32F1 : map ST HAL assert into MBED assert #3381

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 2 commits into from
Dec 19, 2016
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
5 changes: 2 additions & 3 deletions targets/TARGET_STM/TARGET_STM32F1/device/stm32f1xx_hal_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,8 @@
* If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t* file, uint32_t line);
#include "mbed_assert.h"
#define assert_param(expr) MBED_ASSERT(expr)
#else
#define assert_param(expr) ((void)0)
#endif /* USE_FULL_ASSERT */
Expand Down
4 changes: 2 additions & 2 deletions targets/TARGET_STM/TARGET_STM32F1/gpio_irq_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
mode = STM_MODE_IT_FALLING;
obj->event = EDGE_FALL;
} else { // NONE or RISE
mode = STM_MODE_IT_EVT_RESET;
mode = STM_MODE_INPUT;
obj->event = EDGE_NONE;
}
}
Expand All @@ -313,7 +313,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
mode = STM_MODE_IT_RISING;
obj->event = EDGE_RISE;
} else { // NONE or FALL
mode = STM_MODE_IT_EVT_RESET;
mode = STM_MODE_INPUT;
obj->event = EDGE_NONE;
}
}
Expand Down
20 changes: 11 additions & 9 deletions targets/TARGET_STM/TARGET_STM32F1/pinmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void pin_mode(PinName pin, PinMode mode)
// set pull-up => bit=1, set pull-down => bit = 0
if (mode == PullUp) {
gpio->ODR |= (0x01 << (pin_index)); // Set pull-up
} else{
} else {
gpio->ODR &= ~(0x01 << (pin_index)); // Set pull-down
}
break;
Expand All @@ -209,7 +209,8 @@ void pin_mode(PinName pin, PinMode mode)
/* Internal function for setting the gpiomode/function
* without changing Pull mode
*/
void pin_function_gpiomode(PinName pin, uint32_t gpiomode) {
void pin_function_gpiomode(PinName pin, uint32_t gpiomode)
{

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

/* Check if pull/pull down is active */
if ((!(*gpio_reg_hl & (0x03 << shift))) // input
&& (!!(*gpio_reg_hl & (0x08 << shift))) // pull-up / down
&& (!(*gpio_reg_hl & (0x04 << shift)))) { // GPIOx_CRL.CNFx.bit0 = 0
if (!!(gpio->ODR & (0x01 << pin_index))) {
pull = PullUp;
} else {
pull = PullDown;
if (!(*gpio_reg_hl & (0x03 << shift))) {// input
if((!!(*gpio_reg_hl & (0x08 << shift))) // pull-up / down
&& (!(*gpio_reg_hl & (0x04 << shift)))) { // GPIOx_CRL.CNFx.bit0 = 0
if (!!(gpio->ODR & (0x01 << pin_index))) {
pull = PullUp;
} else {
pull = PullDown;
}
}
} else { //output
if (!!(*gpio_reg_hl & (0x04 << shift))) { //open drain
Expand Down
4 changes: 2 additions & 2 deletions targets/TARGET_STM/TARGET_STM32F1/rtc_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ time_t rtc_read(void)
timeinfo.tm_wday = dateStruct.WeekDay;
timeinfo.tm_mon = dateStruct.Month - 1;
timeinfo.tm_mday = dateStruct.Date;
timeinfo.tm_year = dateStruct.Year;
timeinfo.tm_year = dateStruct.Year + 68;
timeinfo.tm_hour = timeStruct.Hours;
timeinfo.tm_min = timeStruct.Minutes;
timeinfo.tm_sec = timeStruct.Seconds;
Expand All @@ -186,7 +186,7 @@ void rtc_write(time_t t)
dateStruct.WeekDay = timeinfo->tm_wday;
dateStruct.Month = timeinfo->tm_mon + 1;
dateStruct.Date = timeinfo->tm_mday;
dateStruct.Year = timeinfo->tm_year;
dateStruct.Year = timeinfo->tm_year - 68;
timeStruct.Hours = timeinfo->tm_hour;
timeStruct.Minutes = timeinfo->tm_min;
timeStruct.Seconds = timeinfo->tm_sec;
Expand Down