diff --git a/src/keyboard.h b/src/keyboard.h index 0379051..3e6158a 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -9,5 +9,5 @@ * ------------------------------------------------------------------------- */ -#include KEYBOARD +#include MAKEFILE_KEYBOARD diff --git a/src/keyboard/ergodox/layout.h b/src/keyboard/ergodox/layout.h index 84dca27..dcc8825 100644 --- a/src/keyboard/ergodox/layout.h +++ b/src/keyboard/ergodox/layout.h @@ -16,7 +16,7 @@ #include "matrix.h" // for number of rows and columns - #include KEYBOARD_LAYOUT // for number of layers + #include MAKEFILE_KEYBOARD_LAYOUT // for number of layers extern uint8_t kb_layout [KB_LAYERS][KB_ROWS][KB_COLUMNS]; diff --git a/src/keyboard/ergodox/mcp23018.c b/src/keyboard/ergodox/mcp23018.c index 9af7fd7..2be6cdd 100644 --- a/src/keyboard/ergodox/mcp23018.c +++ b/src/keyboard/ergodox/mcp23018.c @@ -10,7 +10,7 @@ #include #include "lib/_data-types.h" -#include "lib/_teensy-2-0/twi.h" // `TWI_FREQ` defined in "teensy-2-0.c" +#include "lib/_twi.h" // `TWI_FREQ` defined in "teensy-2-0.c" #define KEYBOARD_INCLUDE_PRIVATE #include "matrix.h" diff --git a/src/keyboard/ergodox/teensy-2-0.c b/src/keyboard/ergodox/teensy-2-0.c index 0a7a6c5..89eda5b 100644 --- a/src/keyboard/ergodox/teensy-2-0.c +++ b/src/keyboard/ergodox/teensy-2-0.c @@ -11,7 +11,7 @@ #include "lib/_data-types.h" #define TWI_FREQ 400000 -#include "lib/_teensy-2-0/twi.h" +#include "lib/_twi.h" #define KEYBOARD_INCLUDE_PRIVATE #include "matrix.h" diff --git a/src/lib/_twi.h b/src/lib/_twi.h new file mode 100644 index 0000000..6803dfa --- /dev/null +++ b/src/lib/_twi.h @@ -0,0 +1,20 @@ +/* ---------------------------------------------------------------------------- + * TWI (I2C) : exports + * + * Code specific to different development boards is used by modifying a + * variable in the makefile. + * ---------------------------------------------------------------------------- + * Copyright (c) 2012 Ben Blazak + * Released under The MIT License (MIT) (see "license.md") + * Project located at + * ------------------------------------------------------------------------- */ + + +#define str(s) #s // stringify +#define expstr(s) str(s) // expand -> stringify +#define inc expstr(_twi/MAKEFILE_BOARD.h) // inc(lude) +#include inc +#undef str +#undef expstr +#undef inc + diff --git a/src/lib/_teensy-2-0/twi.c b/src/lib/_twi/teensy-2-0.c similarity index 93% rename from src/lib/_teensy-2-0/twi.c rename to src/lib/_twi/teensy-2-0.c index 2278aff..41b1949 100644 --- a/src/lib/_teensy-2-0/twi.c +++ b/src/lib/_twi/teensy-2-0.c @@ -3,7 +3,8 @@ * * - This is mostly straight from the datasheet, section 20.6.6, figure 20-11 * (the code example in C), and section 20.8.1, figure 20-12 - * - Also see the documentation for `` at + * - Also see the documentation for `` at + * * * Some other (more complete) TWI libraries for the Teensy 2.0 (and other Atmel * processors): @@ -23,7 +24,7 @@ #include //dbg #include -#include "twi.h" +#include "../_twi.h" void twi_init(void) { diff --git a/src/lib/_teensy-2-0/twi.h b/src/lib/_twi/teensy-2-0.h similarity index 100% rename from src/lib/_teensy-2-0/twi.h rename to src/lib/_twi/teensy-2-0.h diff --git a/src/lib/_teensy-2-0/twi.md b/src/lib/_twi/teensy-2-0.md similarity index 96% rename from src/lib/_teensy-2-0/twi.md rename to src/lib/_twi/teensy-2-0.md index eaa880e..ec511cb 100644 --- a/src/lib/_teensy-2-0/twi.md +++ b/src/lib/_twi/teensy-2-0.md @@ -1,4 +1,4 @@ -# Documentation : Teensy 2.0 I²C +# Documentation : I²C : Teensy 2.0 ## I²C Status Codes (for Master modes) diff --git a/src/makefile b/src/makefile index ce5673d..268fc11 100644 --- a/src/makefile +++ b/src/makefile @@ -15,8 +15,9 @@ TARGET = firmware FORMAT = ihex -KEYBOARD = ergodox # see "src/keyboard" for what's available -LAYOUT = qwerty # see "src/keyboard/*/layout" for what's available +BOARD = teensy-2-0 # see the libraries you're using for what's available +KEYBOARD = ergodox # see "src/keyboard" for what's available +LAYOUT = qwerty # see "src/keyboard/*/layout" for what's available # firmware stuff SRC = $(wildcard *.c) @@ -46,8 +47,9 @@ CFLAGS += -DF_CPU=16000000 # processor frequency; must match initialization # in source CFLAGS += -I. # search for includes in the current directory # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -CFLAGS += -DKEYBOARD='"keyboard/$(strip $(KEYBOARD)).h"' -CFLAGS += -DKEYBOARD_LAYOUT='"layout/$(strip $(LAYOUT)).h"' +CFLAGS += -DMAKEFILE_BOARD='$(strip $(BOARD))' +CFLAGS += -DMAKEFILE_KEYBOARD='"keyboard/$(strip $(KEYBOARD)).h"' +CFLAGS += -DMAKEFILE_KEYBOARD_LAYOUT='"layout/$(strip $(LAYOUT)).h"' # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CFLAGS += -std=gnu99 # use C99 plus GCC extensions CFLAGS += -Os # optimize for size