summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--CMakeLists.txt40
-rw-r--r--ardkbd.c20
3 files changed, 62 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..dee53c5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+build
+*~
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..3e6d2fc
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,40 @@
+cmake_minimum_required(VERSION 2.8.3)
+
+
+SET(BOARD "atmega328" CACHE STRING "AVR CPU to build for")
+SET(CLOCK "16000000" CACHE STRING "CPU clock")
+
+SET(FLASH_FLAGS "-patmega328p" "-carduino" "-P/dev/ttyUSB0" "-b57600" CACHE STRING "avrdude flags")
+
+
+find_program(AVR_GCC avr-gcc)
+find_program(AVRDUDE avrdude)
+
+SET(CMAKE_SYSTEM_NAME Generic)
+
+
+#SET(CWARN "-Wall")
+#SET(CTUNING "-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums")
+#SET(COPT "-Os")
+#SET(CMCU "-mmcu=${BOARD}")
+#SET(CDEFS "-DF_CPU=${CLOCK}")
+
+SET(CMAKE_C_COMPILER ${AVR_GCC})
+
+project(ARDKBD C)
+
+set(CMAKE_MODULE_PATH ${ARDKDB_SOURCE_DIR})
+
+
+add_executable(ardkbd.elf
+ ardkbd.c
+)
+set_target_properties(ardkbd.elf PROPERTIES
+ COMPILE_FLAGS "-Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Os -mmcu=${BOARD}"
+ COMPILE_DEFINITIONS "F_CPU=${CLOCK}"
+)
+
+add_custom_command(OUTPUT ardkbd.hex COMMAND ${CMAKE_OBJCOPY} -O ihex -R .eeprom ardkbd.elf ardkbd.hex DEPENDS ardkbd.elf)
+add_custom_target(ardkbd ALL DEPENDS ardkbd.hex)
+
+add_custom_target(flash COMMAND ${AVRDUDE} ${FLASH_FLAGS} -D -Uflash:w:ardkbd.hex:i DEPENDS ardkbd)
diff --git a/ardkbd.c b/ardkbd.c
new file mode 100644
index 0000000..2107a5d
--- /dev/null
+++ b/ardkbd.c
@@ -0,0 +1,20 @@
+#include <avr/io.h>
+#include <util/delay.h>
+
+
+#include <stdbool.h>
+
+
+
+int main() {
+ DDRB = 0xFF;
+ PORTB = 0;
+
+ while(true) {
+ _delay_ms(1000);
+ PORTB ^= 0x20;
+ }
+
+ return 0;
+}
+