STMicroelectronics / STM32CubeG4

STM32Cube MCU Full Package for the STM32G4 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
182 stars 98 forks source link

HAL_GPIO doesn't have EXTI enable / disable API. #6

Closed suikan4github closed 4 years ago

suikan4github commented 4 years ago

The EXTI interrupt is caught by the HAL_GPIO_EXTI_Callback(). But there is not HAL_GPIO API to enable / disable EXTI.

This is not appropriate design. Some API to enable / disable EXTI for each line should be provided.

ALABSTM commented 4 years ago

Hi Suikan4GitHub,

First of all, thank you for asking the question.

Actually, the EXTI enabling and disabling are handled at HAL_GPIO_Init() and HAL_GPIO_DeInit() levels respectively. I hope you find in the explanations below a satisfying answer to your question.

As for the EXTI enabling, let's examine the GPIO_EXTI example:

With regards,

suikan4github commented 4 years ago

HI ALABSTM

Thank you very much for your explanation.

I still have difficulties to use the HAL_GPIO_Init() and HAL_GPIO_DeInit() as enable / disable the EXTI. The problem is the GPIO_Init parameter of the HAL_GPIO_Init(). This parameter is made by CubeIDE but discarded when the program returns from MX_GPIO_Init(). As a result, the application cannot use the initialization parameter ( Similar parameter exists for the other peripherals, as Init member variable of the peripheral handle ).

So, from the application point of view, explicit enable/disable API is explicit and useful.

Regards, Seiichi

ALABSTM commented 4 years ago

Hi Seiichi,

I hope you are doing well. Depending on the use case you are thinking about, you point might be relevant. However, in this case, it is no more related to the firmware published within this repository. It is rather related to Cube MX or even way you think to design you application.

In both cases, please allow me to redirect you to the ST Community:

Anyway, about the "GPIO_InitStructure" declared locally, may I suggest something? I will use the GPIO_EXTI as example.

I hope this hint is helpful. Do not hesitate to visit the ST Community Forum. There, you will also find support and answers to your questions hopefully.

With regards,

suikan4github commented 4 years ago

Hi ALABSTM

Thank you for your kind reply. I will think of some other way to disable/enable interrupt.

Regards