cancel
Showing results for 
Search instead for 
Did you mean: 

Hi I have problems with STM32CubeIDE and the initialization of the Sensor vl53L0x, the api I import it to the middleswares folder. The error 'undefined reference to DataInit...'.

VDein.1
Associate

#include "main.h"

#include "vl53l0x_i2c_platform.h"

#include "vl53l0x_api.h"

#include "vl53l0x_platform.h"

#include "vl53l0x_platform_log.h"

I2C_HandleTypeDef hi2c1;

RTC_HandleTypeDef hrtc;

/* Private function prototypes -----------------------------------------------*/

void SystemClock_Config(void);

static void MX_GPIO_Init(void);

static void MX_I2C1_Init(void);

static void MX_RTC_Init(void);

/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/

/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**

 * @brief The application entry point.

 * @retval int

 */

int main(void)

{

uint8_t buff =0;

VL53L0X_Error Status = VL53L0X_ERROR_NONE;

VL53L0X_Dev_t MyDevice;

VL53L0X_Dev_t *pMyDevice = &MyDevice;

VL53L0X_Version_t          Version;

VL53L0X_Version_t         *pVersion  = &Version;

VL53L0X_DeviceInfo_t        DeviceInfo;

pMyDevice->I2cDevAddr   = 0x52;

pMyDevice->comms_type   = 1;

pMyDevice->comms_speed_khz = 400;

 /* USER CODE BEGIN 1 */

 /* USER CODE END 1 */

 /* MCU Configuration--------------------------------------------------------*/

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

 HAL_Init();

 /* USER CODE BEGIN Init */

 /* USER CODE END Init */

 /* Configure the system clock */

 SystemClock_Config();

 /* USER CODE BEGIN SysInit */

 /* USER CODE END SysInit */

 /* Initialize all configured peripherals */

 MX_GPIO_Init();

 MX_I2C1_Init();

 MX_RTC_Init();

 /* USER CODE BEGIN 2 */

 VL53L0X_DataInit(pMyDevice); //"undefined reference to DataInit"

 /* USER CODE END 2 */

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

 {

 buff++;

 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_SET);

 HAL_Delay(2000);

 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_RESET);

 HAL_Delay(3000);

  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

 }

 /* USER CODE END 3 */

}

2 REPLIES 2
Wijeden RHIMI
ST Employee

Hello @ VDein.1

I would start by asking about your project structure :

  • Where is this reference to "VL53L0X_DataInit()" located?
  • Is it linked correctly?
  • Are the linked files inside the project or somewhere else?
  • If somewhere else, is those resources linked correctly to the project?

Waiting your feedback !

Wijeden,

VDein.1
Associate

1. VL53L0X_DataInit() this function is in the API, exactly in VL53L0X_api.h.

2. Well, I think it is well linked. To use the API import the API library in the Middleswares folder. Then I went to the Project properties and there I added the paths, in C/c++ Build/Settings/MCU GCC Compiler/Include paths.

I don't know if this is the correct way to link the API_VL53L0X files.

Thanks for your time.

VDein.1