AnsweredAssumed Answered

SM32L1xx Standard Peripherals Library Drivers, IS_RCC_APB1_PERIPH(PERIPH)

Question asked by wyss.daniele on Mar 25, 2014
Latest reply on Mar 28, 2014 by Clive One

I saw on the latest version of STM32L1xx Standard Peripherals Library Drivers,V1.2.0 something that I do not like.

Look at those macros:

In case of RCC_APB2Periph_USART1, both will return TRUE.

///                  100000000000000   ,  
///  1001111000000010011010111000000   , #define IS_RCC_APB1_PERIPH(PERIPH) ((((PERIPH) & 0x4F0135C0) == 0x00) && ((PERIPH) != 0x00)) 
/// 11111111111111111010010111100010   , #define IS_RCC_APB2_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFA5E2) == 0x00) && ((PERIPH) != 0x00))

And look where those are used:
"void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
  /* Check the parameters */


"void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
  /* Check the parameters */

If you analyze a but more you will see that SPI2 and UART1 have the same value.

Now the questions are coming:
1) am I right that this is a mistake?
2) due to the same value of SPI2 and UART1 it is not really possible to make the check using the approach of those macros (therefore not so easy to solve)
3) Does somebody have an idea if this is an exeption or are there other cases?, shall I really "trust" those asserts ?