diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f9696af..2bceba1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,41 @@ -add_executable(main +add_executable(${PROJECT_NAME} main.c ) + +# Ensure the build rules are defined +set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".elf") + +if(NOT TARGET size) +# Set the size utility to display the size of the final binary +add_custom_target(size ALL + COMMAND ${CMAKE_SIZE} --format=avr --mcu=${AVR_MCU} ${CMAKE_PROJECT_NAME}.elf + DEPENDS ${CMAKE_PROJECT_NAME}.elf +) +endif() + + +if(NOT TARGET hex) +# Define how to convert ELF to HEX +add_custom_target(hex ALL + COMMAND ${CMAKE_OBJCOPY} -O ihex -R .eeprom ${CMAKE_PROJECT_NAME}.elf ${CMAKE_PROJECT_NAME}.hex + DEPENDS ${CMAKE_PROJECT_NAME}.elf +) +endif() + + +if(NOT TARGET bin) +# Define how to convert ELF to BIN +add_custom_target(bin ALL + COMMAND ${CMAKE_OBJCOPY} -O binary -R .eeprom ${CMAKE_PROJECT_NAME}.elf ${CMAKE_PROJECT_NAME}.bin + DEPENDS ${CMAKE_PROJECT_NAME}.elf +) +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 + DEPENDS hex +) +endif() diff --git a/src/main.c b/src/main.c index 23fbcc0..89fe62a 100644 --- a/src/main.c +++ b/src/main.c @@ -1,8 +1,61 @@ #include "stdio.h" +#include +#include +#include +#include + + +//############################# +//Globals +//############################# + +#define LED_PIN PB0 + + +//############################# +//Prototypes +//############################# + +void led_blink(void); + + + +//############################# +//MAIN +//############################# + int main(int argc, char **argv) -{ - printf("Hello!\n"); +{ + led_blink(); + + while(1) { + led_blink(); + _delay_ms(500); + } + return 0; } + + + +//############################# +//FUNCTIONS +//############################# + +/* + * Input: None + * Output: None + * Description: Toggles the pin for the LED indicator. + */ +void led_blink(void) { + //Set the DDR for output. + DDRC |= (1<