AnsweredAssumed Answered

Consistent functions signature across different HALs

Question asked by cnoviello on Oct 28, 2015
Latest reply on Oct 29, 2015 by Nesrine M
Hi,
I'd like to say up-front that I'm one of those people thinking that the new CubeHAL is a great improvement compared to the old SPL.

However, still there are things I don't understand. For example, let's consider the HAL_NVIC functions related to interrupt priority. In CubeHALs related to Cortex-M3/4/7 based MCUs we have that the functions to set/get a priority of an IRQ have the following signature:

void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority);
void HAL_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority);

Now, in CubeF0 HAL you have defined the HAL_NVIC_SetPriority() like in the other HALs:

void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority);

Here, the parameter SubPriority is simply ignored because it's meaningless on a Cortex-M0. I think that this could be a good design choice, because it simplifies the portability of application code between different HALs.
But, could you kindly explain me why did you declared the HAL_NVIC_GetPriority() in this way?

uint32_t HAL_NVIC_GetPriority(IRQn_Type IRQn)

I think that it would be best to use the same signature as in other HALs, or to change also the signature of the HAL_NVIC_SetPriority() only for CubeF0/L0.

Just my two cents.

Outcomes