diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..34a3ea7 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,50 @@ +cmake_minimum_required(VERSION 3.13) +project(SIMMProgrammer) + +# Create a list of all source files common to all architectures +set(SOURCES + drivers/mcp23s17.c + drivers/mcp23s17.h + drivers/parallel_flash.c + drivers/parallel_flash.h + hal/board.h + hal/gpio.h + hal/parallel_bus.h + hal/spi.h + hal/usbcdc.h + tests/simm_electrical_test.c + tests/simm_electrical_test.h + chip_id.h + main.c + led.h + programmer_protocol.h + simm_programmer.c + simm_programmer.h + util.h +) + +# Get hardware-specific source files +if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "avr") + include(hal/at90usb646/at90usb646_sources.cmake) +else() + message(FATAL_ERROR "unrecognized architecture for build") +endif() + +# The actual executable, in ELF format +add_executable(SIMMProgrammer.elf ${SOURCES} ${HWSOURCES}) + +# Common compiler options +target_compile_options(SIMMProgrammer.elf PRIVATE + -Wall -Os -ffunction-sections -fdata-sections +) +set_property(TARGET SIMMProgrammer.elf PROPERTY C_STANDARD 99) + +# Common linker options +target_link_options(SIMMProgrammer.elf PRIVATE + -Wl,-Map,SIMMProgrammer.map -Wl,--gc-sections +) + +# Get hardware-specific options +if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "avr") + include(hal/at90usb646/at90usb646_options.cmake) +endif() diff --git a/hal/at90usb646/at90usb646_options.cmake b/hal/at90usb646/at90usb646_options.cmake new file mode 100644 index 0000000..dfc3bf1 --- /dev/null +++ b/hal/at90usb646/at90usb646_options.cmake @@ -0,0 +1,29 @@ +# AVR-specific include paths +target_include_directories(SIMMProgrammer.elf PRIVATE + hal/at90usb646 +) + +# AVR-specific compiler definitions +target_compile_definitions(SIMMProgrammer.elf PRIVATE + F_CPU=16000000UL + F_USB=16000000UL + USE_LUFA_CONFIG_HEADER +) + +# AVR-specific compiler options +target_compile_options(SIMMProgrammer.elf PRIVATE + -fpack-struct -fshort-enums -funsigned-char -funsigned-bitfields -mmcu=at90usb646 +) + +# AVR-specific linker options +target_link_options(SIMMProgrammer.elf PRIVATE + -mmcu=at90usb646 +) + +# AVR-specific command/target to generate .bin file from the ELF file. This program +# is flashed using a bootloader, so there's no need to generate a HEX file. +add_custom_command(OUTPUT SIMMProgrammer.bin + COMMAND ${CMAKE_OBJCOPY} -R .eeprom -O binary SIMMProgrammer.elf SIMMProgrammer.bin + DEPENDS SIMMProgrammer.elf +) +add_custom_target(SIMMProgrammer_bin ALL DEPENDS SIMMProgrammer.bin) diff --git a/hal/at90usb646/at90usb646_sources.cmake b/hal/at90usb646/at90usb646_sources.cmake new file mode 100644 index 0000000..3577227 --- /dev/null +++ b/hal/at90usb646/at90usb646_sources.cmake @@ -0,0 +1,70 @@ +set(HWSOURCES + hal/at90usb646/LUFA/Common/Architectures.h + hal/at90usb646/LUFA/Common/ArchitectureSpecific.h + hal/at90usb646/LUFA/Common/Attributes.h + hal/at90usb646/LUFA/Common/BoardTypes.h + hal/at90usb646/LUFA/Common/Common.h + hal/at90usb646/LUFA/Common/CompilerSpecific.h + hal/at90usb646/LUFA/Common/Endianness.h + hal/at90usb646/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c + hal/at90usb646/LUFA/Drivers/USB/Class/CDCClass.h + hal/at90usb646/LUFA/Drivers/USB/Class/Common/CDCClassCommon.h + hal/at90usb646/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.h + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.h + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c + hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h + hal/at90usb646/LUFA/Drivers/USB/Core/ConfigDescriptor.c + hal/at90usb646/LUFA/Drivers/USB/Core/ConfigDescriptor.h + hal/at90usb646/LUFA/Drivers/USB/Core/DeviceStandardReq.c + hal/at90usb646/LUFA/Drivers/USB/Core/DeviceStandardReq.h + hal/at90usb646/LUFA/Drivers/USB/Core/Device.h + hal/at90usb646/LUFA/Drivers/USB/Core/Endpoint.h + hal/at90usb646/LUFA/Drivers/USB/Core/EndpointStream.h + hal/at90usb646/LUFA/Drivers/USB/Core/Events.c + hal/at90usb646/LUFA/Drivers/USB/Core/Events.h + hal/at90usb646/LUFA/Drivers/USB/Core/Host.h + hal/at90usb646/LUFA/Drivers/USB/Core/HostStandardReq.h + hal/at90usb646/LUFA/Drivers/USB/Core/OTG.h + hal/at90usb646/LUFA/Drivers/USB/Core/Pipe.h + hal/at90usb646/LUFA/Drivers/USB/Core/PipeStream.h + hal/at90usb646/LUFA/Drivers/USB/Core/StdDescriptors.h + hal/at90usb646/LUFA/Drivers/USB/Core/StdRequestType.h + hal/at90usb646/LUFA/Drivers/USB/Core/USBController.h + hal/at90usb646/LUFA/Drivers/USB/Core/USBInterrupt.h + hal/at90usb646/LUFA/Drivers/USB/Core/USBMode.h + hal/at90usb646/LUFA/Drivers/USB/Core/USBTask.c + hal/at90usb646/LUFA/Drivers/USB/Core/USBTask.h + hal/at90usb646/LUFA/Drivers/USB/USB.h + hal/at90usb646/LUFA/Version.h + hal/at90usb646/LUFAConfig.h + + hal/at90usb646/board.c + hal/at90usb646/board_hw.h + hal/at90usb646/cdc_device_definition.c + hal/at90usb646/cdc_device_definition.h + hal/at90usb646/Descriptors.c + hal/at90usb646/Descriptors.h + hal/at90usb646/gpio.c + hal/at90usb646/gpio_hw.h + hal/at90usb646/hardware.h + hal/at90usb646/LUFAConfig.h + hal/at90usb646/parallel_bus.c + hal/at90usb646/spi.c + hal/at90usb646/spi_private.h + hal/at90usb646/usbcdc.c + hal/at90usb646/usbcdc_hw.h +)