jnk0le / AVR-UART-lib

extremly light uart library for AVR 8 bit microcontrollers
MIT License
105 stars 36 forks source link

atmega32u4 failing to build, multiple definition of uart1_hardware_flow_control_init #13

Closed teliot closed 3 years ago

teliot commented 3 years ago

While I strongly believe my issue is in my build environment I am able to compile when I change the -mmcu to atmega328p. The atmega32u4 does not have UBBR or UBBR0 it only has UBRR1 and that might be causing the issue. However I do see the 32u4 in the header.

pio run -v
Processing atmega32u4 (platform: atmelavr; board_build.mcu: atmega32u4; board_build.f_cpu: 16000000L; upload_protocol: arduino; upload_speed: 115200; build_unflags: -std=gnu11; build_flags: -std=gnu99)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------HARDWARE: ATMEGA32U4 16MHz,
PACKAGES: 
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 4 compatible libraries
More details about "Library Compatibility Mode": https://docs.platformio.org/page/librarymanager/ldf.html#ldf-compat-mode
Scanning dependencies...
Dependency Graph
|-- <usart> (D:\Documents\OneDrive\Documents\PlatformIO\Projects\delme\lib\usart)
Building in release mode
avr-gcc -o .pio\build\atmega32u4\src\main.o -c -fno-fat-lto-objects -std=gnu99 -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega32u4 -DF_CPU=16000000L -DPLATFORMIO=50101 -Iinclude -Isrc -Ilib\usart src\main.c
avr-gcc -o .pio\build\atmega32u4\libbd1\usart\usart.o -c -fno-fat-lto-objects -std=gnu99 -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega32u4 -DF_CPU=16000000L -DPLATFORMIO=50101 -Ilib\usart lib\usart\usart.c
In file included from src\main.c:8:0:
lib\usart/usart.h:1439:7: warning: always_inline function might not be inlinable [-Wattributes]
  void uart1_hardware_flow_control_init(uint8_t ctsenable, uint8_t rtsenable) // pass true to enable
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from lib\usart\usart.c:18:0:
lib\usart\usart.h:1439:7: warning: always_inline function might not be inlinable [-Wattributes]
  void uart1_hardware_flow_control_init(uint8_t ctsenable, uint8_t rtsenable) // pass true to enable
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
avr-gcc-ar rc .pio\build\atmega32u4\libbd1\libusart.a .pio\build\atmega32u4\libbd1\usart\usart.o
avr-gcc -o .pio\build\atmega32u4\firmware.elf -Os -mmcu=atmega32u4 -Wl,--gc-sections -flto -fuse-linker-plugin .pio\build\atmega32u4\src\main.o -L.pio\build\atmega32u4 -Wl,--start-group .pio\build\atmega32u4\libbd1\libusart.a -lm -Wl,--end-group
usart.o (symbol from plugin): In function `uart1_hardware_flow_control_init':
(.text+0x0): multiple definition of `uart1_hardware_flow_control_init'
.pio\build\atmega32u4\src\main.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\atmega32u4\firmware.elf] Error 1
================================================================================================== [FAILED] Took 1.66 seconds ==================================================================================================

and the main.c file

#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <stdio.h>
#include <string.h>

#include "usart.h"

int main (void) {

  DDRB = 1 << 5;

  sei();
  uart1_init(BAUD_CALC(115200));
  uart1_putc('c');

  while (1) {
    _delay_ms(500);
    PORTB ^= 1 << 5;
  }

  return 0;
}