AnsweredAssumed Answered

Bugs in stm32f10x LL library

Question asked by khazanskii.roman on Aug 21, 2017
Latest reply on Dec 1, 2017 by Max Zulus

I tried to use LL library for stm32f10x without CubeMX (  * @version V1.1.1  * @date: 12-May-2017) and almost immediately found some problems:

 

1) You can't actually download LL library without CubeMX, even if you don't want to use Cube. That's not a but, that's just irritating.

 

2) It seems that you can't enable clocking of any periphery because there is no equivalent of RCC_AHBPeriphClockCmd in ll_rcc module.

 

3) If I enabled GPIO blocking with something like RCC->APB2ENR |= RCC_APB2ENR_IOPCEN; and then try to do:

 

    RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;
    
    LL_GPIO_InitTypeDef initStruct;
    LL_GPIO_StructInit( &initStruct );
    
    initStruct.Mode = LL_GPIO_MODE_OUTPUT_10MHz;
    initStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
    initStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
    initStruct.Pin = LL_GPIO_PIN_9; // that equals 0x04020002
    
    LL_GPIO_Init( GPIOC, &initStruct )

 

This code will actually init PC.2 to output push-pull.

Why? LL_GPIO_Init does this:

 

    pinpos = POSITION_VAL(GPIO_InitStruct->Pin);

 

where

 

    #define POSITION_VAL(VAL)     (__CLZ(__RBIT(VAL)))

 

obviously, pinpos will be equal to 1.

 

Then current pin will be calculated like this:

 

    currentpin = (GPIO_InitStruct->Pin) & (0x00000101U << pinpos);

 

so currentpint will be equal to 2.

 

And then

 

    LL_GPIO_SetPinMode(GPIOx, currentpin, GPIO_InitStruct->Mode);

 

will be called, despite the fact that LL_GPIO_SetPinMode should accept parameters like LL_GPIO_PIN_x.

 

4) And here we have another 'bug' - all inline functions in header files do not check their arguments with assert_param!

 

I'm actually startled, how something as simple as this can be broken and not tested?! Or maybe i'm horribly wrong and just using LL library in the wrong way?

Outcomes