Thanks to visit codestin.com
Credit goes to github.com

Skip to content

L4 integration: Modification to mphalport. #1921

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

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions stmhal/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio) {
} else if (gpio == GPIOH) {
__GPIOH_CLK_ENABLE();
#endif
#ifdef __GPIOI_CLK_ENABLE
#if defined(GPIOI) && defined(__GPIOI_CLK_ENABLE)
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the reason for this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

__GPIOI_CLK_ENABLE on L4 is defined in h1l/l4/inc/Legacy/stm32_hal_legacy.h, line 2214 as __HAL_RCC_GPIOI_CLK_ENABLE and this is no further defined on the l4 platform. Therefore I added the test for GPIOI which is not defined on l4 platform and both functions are needed to fullfill the code. According to the Reference Manual (RM0351, P277) the port can be A.H and there is no I, J ....

An alternative would be to check for the MCU_SERIES_L4 define.

Copy link
Contributor

Choose a reason for hiding this comment

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

I ran into some of these when doing the M7 port as well.
Upgrading the latest F4 HAL (and changing all of the old defintions to the new ones) would help, then we could get rid of the legacy definitions. But that's also alot of work.

} else if (gpio == GPIOI) {
__GPIOI_CLK_ENABLE();
#endif
#ifdef __GPIOJ_CLK_ENABLE
#if defined(GPIOJ) && defined(__GPIOJ_CLK_ENABLE)
} else if (gpio == GPIOJ) {
__GPIOJ_CLK_ENABLE();
#endif
#ifdef __GPIOK_CLK_ENABLE
#if defined(GPIOK) && defined(__GPIOK_CLK_ENABLE)
} else if (gpio == GPIOK) {
__GPIOK_CLK_ENABLE();
#endif
Expand Down
4 changes: 3 additions & 1 deletion stmhal/mphalport.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
#define MP_HAL_UNIQUE_ID_ADDRESS (0x1fff7a10)
#elif defined(MCU_SERIES_F7)
#define MP_HAL_UNIQUE_ID_ADDRESS (0x1ff0f420)
#elif defined(MCU_SERIES_L4)
#define MP_HAL_UNIQUE_ID_ADDRESS (0x1fff7590)
#else
#error mphalport.h: Unrecognized MCU_SERIES
#endif

// Basic GPIO functions
#define GPIO_read_pin(gpio, pin) (((gpio)->IDR >> (pin)) & 1)
#if defined(MCU_SERIES_F7)
#if defined(MCU_SERIES_F7) || defined(MCU_SERIES_L4)
#define GPIO_set_pin(gpio, pin_mask) (((gpio)->BSRR) = (pin_mask))
#define GPIO_clear_pin(gpio, pin_mask) (((gpio)->BSRR) = ((pin_mask) << 16))
#else
Expand Down