Page 1 of 1

[SOLVED] error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Posted: Mon Mar 16, 2020 5:52 pm
by lucky62
Hello i am trying to set the bluepill clock and then check.
Here is the whole program (it is a skeleton for I2C-DMA transfer):

Code: Select all

#include "stm32f1xx.h"
#include "stm32f1xx_ll_bus.h"
#include "stm32f1xx_ll_gpio.h"
#include "stm32f1xx_ll_utils.h"
#include "stm32f1xx_ll_rcc.h"
#include "stm32f1xx_ll_system.h"

void setupClock(void) {
  // 72MHz from 8MHz HSE
  LL_UTILS_PLLInitTypeDef pll;
  pll.Prediv = LL_RCC_PREDIV_DIV_1; // 8MHz / 1 = 8MHz
  pll.PLLMul = LL_RCC_PLL_MUL_9;    // 8MHz * 9 = 72MHz
  LL_UTILS_ClkInitTypeDef clk;
  clk.AHBCLKDivider = LL_RCC_SYSCLK_DIV_1;
  clk.APB1CLKDivider = LL_RCC_APB1_DIV_2;
  clk.APB2CLKDivider = LL_RCC_APB2_DIV_1;
  // configure clock
  LL_PLL_ConfigSystemClock_HSE(8000000,LL_UTILS_HSEBYPASS_OFF,&pll,&clk);
  SystemCoreClockUpdate();
  Serial.print("SystemCoreClock: ");
  Serial.println(SystemCoreClock);
}

void setupDMA(void) {}
void setupI2C(void) {}

void setup() {
  Serial.begin(115200);
  setupClock();
  // spočítej a uož frekvence SYSCLK,AHB a APB do struktury "clocks"
  LL_RCC_ClocksTypeDef clocks; // <-- !!! this line is causing error
  LL_RCC_GetSystemClocksFreq(&clocks); // <-- !!! this line too
  setupI2C();
  setupDMA();
}

void loop() {
  Serial.print(".");
  delay( 1000 );
}
When I am trying to compile it then I got the error - 'LL_RCC_ClocksTypeDef' was not declared in this scope at this line:
LL_RCC_ClocksTypeDef clocks;
When this line (and next one) is commented out then program is compiled successfully.

Most of LL_RCC_* functions/constants are defined in file stm32f1xx_ll_rcc.h - including others, which are used without problems.

Just I observed that LL_RCC_ClocksTypeDef is compiled conditionally by:
#if defined(USE_FULL_LL_DRIVER)
What is purpose of variable USE_FULL_LL_DRIVER and where/when it should be defined?

Re: error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Posted: Mon Mar 16, 2020 6:45 pm
by fpiSTM
Define it before the include

Re: error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Posted: Mon Mar 16, 2020 8:10 pm
by lucky62
I tried this already, but problem was not solved.
Compilator was ok, but linker failed with error:
undefined reference to `LL_RCC_GetSystemClocksFreq'
BTW - what is the meanings of USE_FULL_LL_DRIVER config?

Re: error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Posted: Mon Mar 16, 2020 8:46 pm
by fpiSTM
Add a file named hal_conf_extra.h with the #define USE_FULL_LL_DRIVER
Or a build_opt.h file with -DUSE_FULL_LL_DRIVER
About the switch:
https://www.google.com/url?sa=t&source= ... 9L88TasRoS
The definition of these LL initialization functions and associated resources (structure, literals and prototypes) is
conditioned by a compilation switch: USE_FULL_LL_DRIVER. To use these functions, this switch must be added
in the toolchain compiler preprocessor or to any generic header file which is processed before the LL drivers

Re: error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Posted: Tue Mar 17, 2020 6:05 am
by lucky62
I added the half_conf_extra.h file with the #define USE_FULL_LL_DRIVER to the project, but result is the same as with this define in main sketch.

compilation is fine but linker failed:
SineWaveGenerator2.ino.cpp:(.text.setup+0x12): undefined reference to `LL_RCC_GetSystemClocksFreq'
collect2: error: ld returned 1 exit status
Using library SrcWrapper at version 1.0.1 in folder: /arduino/portable/packages/STM32/hardware/stm32/1.8.0/libraries/SrcWrapper
exit status 1
Error compiling for board Generic STM32F1 series.
Verbose build.log attached.

Re: error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Posted: Tue Mar 17, 2020 7:00 am
by lucky62
Solution was found here.
Thank! Indeed the file "build_opt.h" in the sketch directory with a string "-DUSE_FULL_LL_DRIVER" completely solved the problem.

Re: [SOLVED] error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Posted: Tue Mar 17, 2020 7:20 am
by fpiSTM
I've also added this solution in my previous post 🙄