2025-01-29 02:24 AM - edited 2025-01-29 03:50 AM
Hello,
I am trying to get my STM32WB5MM module to talk to VL53L7CH.
I have working BLE project (compiles no warnings, no error and works-advertises as beacon). Now I added files from STSW-IMG043, according to doc file in the package.
I also modified the platform.c file, with I2C functions (used the ones from F401 example, just changed the I2C handle to the one I use "hi2c3").
After trying to compile, I receive some weird errors in log that I haven't dealt with before, so some help would be appreciated. From what I could extract, there are some "wrong" definitions in file "vl53lmz_buffers.h" (haven't modified that file at all).
Log output:
11:14:34 **** Incremental Build of configuration Debug for project XXXXX ****
make -j16 all
arm-none-eabi-gcc -o "FPulse.elf" @"objects.list" -mcpu=cortex-m4 -T"C:\Users\klemen.skorjanc\Documents\CubeIDE_workspace\FPulse\STM32WB5MMGHX_FLASH.ld" --specs=nosys.specs -Wl,-Map="FPulse.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
C:/ST/STM32CubeIDE_1.11.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.1.0.202410251130/tools/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Core/Src/vl53lmz_api.o:C:/Users/klemen.skorjanc/Documents/CubeIDE_workspace/FPulse/Debug/../Core/Inc/vl53lmz_buffers.h:35: multiple definition of `VL53LMZ_FIRMWARE'; ./Core/Src/main.o:C:/Users/klemen.skorjanc/Documents/CubeIDE_workspace/FPulse/Debug/../Core/Inc/vl53lmz_buffers.h:35: first defined here
C:/ST/STM32CubeIDE_1.11.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.1.0.202410251130/tools/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Core/Src/vl53lmz_api.o:C:/Users/klemen.skorjanc/Documents/CubeIDE_workspace/FPulse/Debug/../Core/Inc/vl53lmz_buffers.h:21549: multiple definition of `VL53L8_DEFAULT_CONFIGURATION'; ./Core/Src/main.o:C:/Users/klemen.skorjanc/Documents/CubeIDE_workspace/FPulse/Debug/../Core/Inc/vl53lmz_buffers.h:21549: first defined here
C:/ST/STM32CubeIDE_1.11.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.1.0.202410251130/tools/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Core/Src/vl53lmz_api.o:C:/Users/klemen.skorjanc/Documents/CubeIDE_workspace/FPulse/Debug/../Core/Inc/vl53lmz_buffers.h:21800: multiple definition of `VL53L7_DEFAULT_CONFIGURATION'; ./Core/Src/main.o:C:/Users/klemen.skorjanc/Documents/CubeIDE_workspace/FPulse/Debug/../Core/Inc/vl53lmz_buffers.h:21800: first defined here
C:/ST/STM32CubeIDE_1.11.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.1.0.202410251130/tools/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Core/Src/vl53lmz_api.o:C:/Users/klemen.skorjanc/Documents/CubeIDE_workspace/FPulse/Debug/../Core/Inc/vl53lmz_buffers.h:22051: multiple definition of `VL53LMZ_DEFAULT_XTALK'; ./Core/Src/main.o:C:/Users/klemen.skorjanc/Documents/CubeIDE_workspace/FPulse/Debug/../Core/Inc/vl53lmz_buffers.h:22051: first defined here
C:/ST/STM32CubeIDE_1.11.2/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.1.0.202410251130/tools/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Core/Src/vl53lmz_api.o:C:/Users/klemen.skorjanc/Documents/CubeIDE_workspace/FPulse/Debug/../Core/Inc/vl53lmz_buffers.h:22252: multiple definition of `VL53LMZ_GET_NVM_CMD'; ./Core/Src/main.o:C:/Users/klemen.skorjanc/Documents/CubeIDE_workspace/FPulse/Debug/../Core/Inc/vl53lmz_buffers.h:22252: first defined here
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:74: FPulse.elf] Error 1
"make -j16 all" terminated with exit code 2. Build might be incomplete.
11:14:35 Build Failed. 6 errors, 0 warnings. (took 793ms)
"Platform.c" file that I modified:
/*******************************************************************************
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
*
* This file is part of the VL53LMZ Ultra Lite Driver and is dual licensed,
* either 'STMicroelectronics Proprietary license'
* or 'BSD 3-clause "New" or "Revised" License' , at your option.
*
********************************************************************************
*
* 'STMicroelectronics Proprietary license'
*
********************************************************************************
*
* License terms: STMicroelectronics Proprietary in accordance with licensing
* terms at www.st.com/sla0081
*
* STMicroelectronics confidential
* Reproduction and Communication of this document is strictly prohibited unless
* specifically authorized in writing by STMicroelectronics.
*
*
********************************************************************************
*
* Alternatively, the VL53LMZ Ultra Lite Driver may be distributed under the
* terms of 'BSD 3-clause "New" or "Revised" License', in which case the
* following provisions apply instead of the ones mentioned above :
*
********************************************************************************
*
* License terms: BSD 3-clause "New" or "Revised" License.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "platform.h"
#include "main.h"
uint8_t RdByte(
VL53LMZ_Platform *p_platform,
uint16_t RegisterAdress,
uint8_t *p_value)
{
uint8_t status = 255;
uint8_t data_write[2];
uint8_t data_read[1];
data_write[0] = (RegisterAdress >> & 0xFF;
data_write[1] = RegisterAdress & 0xFF;
status = HAL_I2C_Master_Transmit(I2C3, p_platform->address, data_write, 2, 100);
status = HAL_I2C_Master_Receive(I2C3, p_platform->address, data_read, 1, 100);
return status;
}
uint8_t WrByte(
VL53LMZ_Platform *p_platform,
uint16_t RegisterAdress,
uint8_t value)
{
uint8_t data_write[3];
uint8_t status = 255;
data_write[0] = (RegisterAdress >> & 0xFF;
data_write[1] = RegisterAdress & 0xFF;
data_write[2] = value & 0xFF;
status = HAL_I2C_Master_Transmit(I2C3, p_platform->address, data_write, 3, 100);
return status;
}
uint8_t WrMulti(
VL53LMZ_Platform *p_platform,
uint16_t RegisterAdress,
uint8_t *p_values,
uint32_t size)
{
uint8_t status = HAL_I2C_Mem_Write(I2C3, p_platform->address, RegisterAdress,
I2C_MEMADD_SIZE_16BIT, p_values, size, 65535);
return status;
}
uint8_t RdMulti(
VL53LMZ_Platform *p_platform,
uint16_t RegisterAdress,
uint8_t *p_values,
uint32_t size)
{
uint8_t status = 255;
uint8_t data_write[2];
data_write[0] = (RegisterAdress>>8) & 0xFF;
data_write[1] = RegisterAdress & 0xFF;
status = HAL_I2C_Master_Transmit(I2C3, p_platform->address, data_write, 2, 10);
status += HAL_I2C_Master_Receive(I2C3, p_platform->address, p_values, size, 400);
return status;
}
uint8_t Reset_Sensor(
VL53LMZ_Platform *p_platform)
{
uint8_t status = 0;
/* (Optional) Need to be implemented by customer. This function returns 0 if OK */
/* Set pin LPN to LOW */
/* Set pin AVDD to LOW */
/* Set pin VDDIO to LOW */
WaitMs(p_platform, 100);
/* Set pin LPN of to HIGH */
/* Set pin AVDD of to HIGH */
/* Set pin VDDIO of to HIGH */
WaitMs(p_platform, 100);
return status;
}
void SwapBuffer(
uint8_t *buffer,
uint16_t size)
{
uint32_t i, tmp;
/* Example of possible implementation using <string.h> */
for(i = 0; i < size; i = i + 4)
{
tmp = (
buffer[i]<<24)
|(buffer[i+1]<<16)
|(buffer[i+2]<<8)
|(buffer[i+3]);
memcpy(&(buffer[i]), &tmp, 4);
}
}
uint8_t WaitMs(
VL53LMZ_Platform *p_platform,
uint32_t TimeMs)
{
HAL_Delay(TimeMs);
return 0;
}
And view of my project explorer(didn't add plugin files for now):
Solved! Go to Solution.
2025-01-29 05:04 AM
I found the error, I included.h file in two isntances, which caused "multiple definition" errors
2025-01-29 05:04 AM
I found the error, I included.h file in two isntances, which caused "multiple definition" errors