Unexpected behaviour of LL_EXTI_TRIGGER_NONE in LL_EXTI_Init
The way LL_EXTI_Init is written in all of the cube APIs means if you do this:
LL_EXTI_InitTypeDef exti_config = {
.Line_0_31 = foo,
.LineCommand = ENABLE,
.Mode = LL_EXTI_MODE_IT,
.Trigger = LL_EXTI_TRIGGER_NONE,
};
LL_EXTI_Init(&exti_config);
The LL_EXTI_Init function will take no action, but will return SUCCESS.
This is a problem if the EXTI trigger mode was previously set to something other than LL_EXTI_TRIGGER_NONE, because the EXTI trigger will left enabled, with no clear error.
Granted of course I can just change my code to set the LineCommand to DISABLE instead to remove the trigger, but it seems a bit counter-intuitive that LL_EXTI_TRIGGER_NONE doesn't clear the triggers.
It would be useful if LL_EXTI_TRIGGER_NONE was added to the case statement:
case LL_EXTI_TRIGGER_RISING_FALLING:
LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
break;
case LL_EXTI_TRIGGER_NONE:
LL_EXTI_DisableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
LL_EXTI_DisableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
break;
default:
status |= 0x02u;
break;Or at the very least, just remove the surrounding if statement
if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE)
{
switch (EXTI_InitStruct->Trigger)
...
default:
status |= 0x02u;
break;
}so that if the user provides LL_EXTI_TRIGGER_NONE, the default branch will be executed to generate an error.
Thanks
