Added flags for the programmer and port needed for using an uno R3

This commit is contained in:
jakeg00dwin 2024-06-14 16:07:10 -07:00
parent 144fc068ae
commit 3e550f4ac5
2 changed files with 13 additions and 5 deletions

View File

@ -14,12 +14,20 @@ set(AVR_MCU atmega328p) # The old Classic
#set(AVR_MCU avr64dd28) # Newer DX series, avrxmega2
# The default frequency of an 328p devboard using the external crystal.
#set(F_CPU 16000000)
set(F_CPU 16000000UL)
#set(F_CPU 8000000)
add_compile_definitions(F_CPU=16000000UL)
add_compile_definitions(F_CPU=${F_CPU})
# add_compile_definitions(MCU=atmega328p)
add_compile_definitions(__AVR_ATmega328P__)
# Set up the programmer for it
#set(PROGRAMMER usbasp-clone)
set(PROGRAMMER arduino)
# Set the Port for the programmer
set(PORT /dev/ttyUSB0)
# Define the toolchain executables
set(CMAKE_C_COMPILER avr-gcc)
set(CMAKE_CXX_COMPILER avr-g++)
@ -33,8 +41,8 @@ set(CMAKE_SIZE avr-size)
#set(CMAKE_C_FLAGS_INIT "-mmcu=${AVR_MCU} -DF_CPU=16000000UL")
#set(CMAKE_CXX_FLAGS_INIT "-mmcu=${AVR_MCU} -DF_CPU=16000000UL")
#set(CMAKE_EXE_LINKER_FLAGS_INIT "-mmcu=${AVR_MCU}")
set(CMAKE_C_FLAGS " -Os -mmcu=${AVR_MCU} -DF_CPU=16000000UL")
set(CMAKE_CXX_FLAGS "-mmcu=${AVR_MCU} -DF_CPU=16000000UL")
set(CMAKE_C_FLAGS " -Os -mmcu=${AVR_MCU} -DF_CPU=${F_CPU}")
set(CMAKE_CXX_FLAGS "-mmcu=${AVR_MCU} -DF_CPU=${F_CPU}")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-mmcu=${AVR_MCU}")

View File

@ -34,7 +34,7 @@ endif()
if(NOT TARGET upload)
# Upload command (adjust according to your programmer)
add_custom_target(upload ALL
COMMAND avrdude -c usbtiny -p ${AVR_MCU} -U flash:w:${CMAKE_PROJECT_NAME}.hex
COMMAND avrdude -c ${PROGRAMMER} -P ${PORT} -p ${AVR_MCU} -U flash:w:${CMAKE_PROJECT_NAME}.hex
DEPENDS hex
)
endif()