(messing with makefiles; not working yet)
parent
a5e2c20a84
commit
a12a83b555
|
@ -43,6 +43,8 @@ void kb__led__on (uint8_t led);
|
|||
void kb__led__off (uint8_t led);
|
||||
void kb__led__set (uint8_t led, float n);
|
||||
// -------
|
||||
bool kb__led__read (uint8_t led);
|
||||
// -------
|
||||
void kb__led__all_on (void);
|
||||
void kb__led__all_off (void);
|
||||
void kb__led__all_set (float percent);
|
||||
|
@ -164,6 +166,25 @@ void kb__layout__exec_key (bool pressed, uint8_t row, uint8_t column);
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// === kb__led__read() ===
|
||||
/** functions/kb__led__read/description
|
||||
* Return whether the given LED is on (`true`) or off (`false`)
|
||||
*
|
||||
* Arguments:
|
||||
* - `led`: The number of the LED to read. Should be an integer between 1 and
|
||||
* 5 inclusive; behavior is undefined otherwise.
|
||||
*
|
||||
* Returns:
|
||||
* - success: `true` if the given LED is on, and `false` otherwise; LEDs that
|
||||
* don't exist (and can't be set) should always be `false`
|
||||
*
|
||||
* Notes:
|
||||
* - For US keyboards, likely only LEDs 1 through 3 will be physically present;
|
||||
* but the function should handle 4 through 5 gracefully anyway.
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// === kb__led__all_on() ===
|
||||
/** functions/kb__led__all_on/description
|
||||
* Set all the LEDs 'on'.
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
* Code is specific to Teensy 2.0
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
|
@ -57,6 +58,18 @@ void kb__led__set(uint8_t led, float n) {
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
bool kb__led__read(uint8_t led) {
|
||||
switch(led) {
|
||||
case 1: return (PINB & (1<<5)); // topmost
|
||||
case 2: return (PINB & (1<<6)); // middle
|
||||
case 3: return (PINB & (1<<7)); // bottommost
|
||||
case 4: return false;
|
||||
case 5: return false;
|
||||
};
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
void kb__led__all_on(void) {
|
||||
for(int8_t i=1; i<=3; i++)
|
||||
kb__led__on(i);
|
||||
|
|
|
@ -11,11 +11,24 @@
|
|||
#
|
||||
|
||||
|
||||
include ../../../firmware/lib/twi/options.mk
|
||||
include ../../../firmware/lib/usb/options.mk
|
||||
include ../../../firmware/lib/layout/eeprom-macro/options.mk
|
||||
include ../../../firmware/lib/layout/key-functions/options.mk
|
||||
include ../../../firmware/lib/layout/layer-stack/options.mk
|
||||
OLD_CURDIR := $(CURDIR)
|
||||
# -------
|
||||
CURDIR := $(OLD_CURDIR)/../../../firmware/lib/twi
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(OLD_CURDIR)/../../../firmware/lib/usb
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(OLD_CURDIR)/../../../firmware/lib/layout/eeprom-macro
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(OLD_CURDIR)/../../../firmware/lib/layout/key-functions
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(OLD_CURDIR)/../../../firmware/lib/layout/layer-stack
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(OLD_CURDIR)
|
||||
|
||||
|
||||
BINARY_FORMAT := ihex
|
||||
|
@ -25,7 +38,8 @@ MCU := atmega32u4
|
|||
# processor type (for the teensy 2.0)
|
||||
|
||||
F_CPU := 16000000
|
||||
# processor speed, in Hz; max value is 16000000 (16MHz)
|
||||
# processor speed, in Hz; max value is 16000000 (16MHz); must match
|
||||
# initialization in source
|
||||
|
||||
KEYBOARD_LAYOUT := qwerty-kinesis-mod
|
||||
# default layout for this keyboard
|
||||
|
@ -38,9 +52,9 @@ KEYBOARD_LAYOUTS := \
|
|||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SCR += $(wildcard *.c)
|
||||
SRC += $(wildcard controller/*.c)
|
||||
SRC += $(wildcard layout/$(KEYBOARD_LAYOUT)*.c)
|
||||
SCR += $(wildcard $(CURDIR)/*.c)
|
||||
SRC += $(wildcard $(CURDIR)/controller/*.c)
|
||||
SRC += $(wildcard $(CURDIR)/layout/$(KEYBOARD_LAYOUT)*.c)
|
||||
|
||||
CFLAGS += -include $(wildcard options.h)
|
||||
CFLAGS += -include $(wildcard $(CURDIR)/options.h)
|
||||
|
||||
|
|
|
@ -11,5 +11,5 @@
|
|||
#
|
||||
|
||||
|
||||
SRC += $(wildcard $(MCU).c)
|
||||
SRC += $(wildcard $(CURDIR)/$(MCU).c)
|
||||
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
#
|
||||
|
||||
|
||||
SRC += $(wildcard *.c)
|
||||
SRC += $(wildcard device/$(MCU).c)
|
||||
SRC += $(wildcard $(CURDIR)/*.c)
|
||||
SRC += $(wildcard $(CURDIR)/device/$(MCU).c)
|
||||
|
||||
|
|
|
@ -11,5 +11,5 @@
|
|||
#
|
||||
|
||||
|
||||
SRC += $(wildcard *.c)
|
||||
SRC += $(wildcard $(CURDIR)/*.c)
|
||||
|
||||
|
|
|
@ -11,5 +11,5 @@
|
|||
#
|
||||
|
||||
|
||||
SRC += $(wildcard $(MCU).c)
|
||||
SRC += $(CURDIR)/$(MCU).c
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
#
|
||||
|
||||
|
||||
SRC += $(wildcard $(MCU)/*.c)
|
||||
SRC += $(wildcard $(CURDIR)/$(MCU)/*.c)
|
||||
|
||||
ifeq '$(MCU)' 'atmega32u4'
|
||||
SRC += $(wildcard $(MCU)/keyboard/from-pjrc/*.c)
|
||||
SRC += $(wildcard $(CURDIR)/$(MCU)/keyboard/from-pjrc/*.c)
|
||||
endif
|
||||
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
# -----------------------------------------------------------------------------
|
||||
# Copyright (c) 2012, 2013 Ben Blazak <benblazak.dev@gmail.com>
|
||||
# Released under The MIT License (see "doc/license.md")
|
||||
# Project located at <https://github.com/benblazak/ergodox-firmware>
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
## description
|
||||
# Makefile for the firmware
|
||||
#
|
||||
# See '.../firmware/keyboard/.../options.mk' for options
|
||||
#
|
||||
# Notes:
|
||||
# - '.h' file dependencies are automatically generated
|
||||
#
|
||||
# History:
|
||||
# - This makefile was originally (extensively) modified from the WinAVR
|
||||
# makefile template, mostly by removing stuff. The copy I used was from
|
||||
# [pjrc : usb_keyboard] (http://pjrc.com/teensy/usb_keyboard.zip).
|
||||
#
|
||||
|
||||
# TODO: generate symbol table ('.sym' file) instead of the '.map' file
|
||||
# - (make sure it's more readable first)
|
||||
# - (change the documentation (search for '.map' in this file))
|
||||
# - use 'avr-nm' to generate $(TARGET).sym separately from the compile
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
KEYBOARD_NAME := ergodox
|
||||
# the name of the keyboard to build a firmware for
|
||||
|
||||
TARGET := firmware
|
||||
# default name for the '.hex', '.eep', and '.map' files we'll be generating
|
||||
|
||||
OLD_CURDIR := $(CURDIR)
|
||||
# -------
|
||||
CURDIR := $(CURDIR)/keyboard/$(KEYBOARD_NAME)
|
||||
include $(CURDIR)/options.mk
|
||||
# (the place for everything a keyboard implementation might want to change)
|
||||
# -------
|
||||
CURDIR := $(OLD_CURDIR)
|
||||
|
||||
SRC += $(CURDIR)/main.c
|
||||
# (other source files included through the makefile included above)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
CFLAGS := -mmcu=$(MCU) # processor type; must match real life
|
||||
CFLAGS += -DF_CPU=$(F_CPU) # processor frequency; must match initialization
|
||||
# in source
|
||||
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
CFLAGS += -std=gnu99 # use C99 plus GCC extensions
|
||||
CFLAGS += -Os # optimize for size
|
||||
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
CFLAGS += -Wall # enable lots of common warnings
|
||||
CFLAGS += -Wstrict-prototypes # "warn if a function is declared or defined
|
||||
# without specifying the argument types"
|
||||
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
CFLAGS += -fpack-struct # "pack all structure members together without holes"
|
||||
CFLAGS += -fshort-enums # "allocate to an 'enum' type only as many bytes as it
|
||||
# needs for the declared range of possible values"
|
||||
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
CFLAGS += -ffunction-sections # \ "place each function or data into its own
|
||||
CFLAGS += -fdata-sections # / section in the output file if the
|
||||
# target supports arbitrary sections." for
|
||||
# linker optimizations, and discarding
|
||||
# unused code.
|
||||
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
LDFLAGS := -Wl,-Map=$(TARGET).map,--cref # generate a link map, with a cross
|
||||
# reference table
|
||||
LDFLAGS += -Wl,--relax # for some linker optimizations
|
||||
LDFLAGS += -Wl,--gc-sections # discard unused functions and data
|
||||
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
GENDEPFLAGS += -MMD -MP -MF '$@.dep' # generate dependency files
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
CC := avr-gcc
|
||||
OBJCOPY := avr-objcopy
|
||||
SIZE := avr-size
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
OBJ = $(SRC:%.c=%.o)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(TARGET).hex $(TARGET).eep
|
||||
@echo
|
||||
@echo '---------------------------------------------------------------'
|
||||
@echo '------- done --------------------------------------------------'
|
||||
@echo
|
||||
$(SIZE) --target=$(FORMAT) $(TARGET).hex
|
||||
@echo
|
||||
$(SIZE) --target=$(FORMAT) $(TARGET).eep
|
||||
@echo
|
||||
@echo 'you can load "$(TARGET).hex" and "$(TARGET).eep" onto the'
|
||||
@echo 'Teensy using the Teensy loader'
|
||||
@echo
|
||||
@echo '---------------------------------------------------------------'
|
||||
@echo
|
||||
|
||||
clean:
|
||||
@echo
|
||||
@echo '--- cleaning ---'
|
||||
git clean -dX # remove ignored files and directories
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
.SECONDARY:
|
||||
|
||||
%.hex: %.elf
|
||||
@echo
|
||||
@echo '--- making $@ ---'
|
||||
# from the WinAVR makefile template (modified)
|
||||
$(OBJCOPY) -O $(FORMAT) \
|
||||
-R .eeprom -R .fuse -R .lock -R .signature \
|
||||
'$<' '$@'
|
||||
|
||||
%.eep: %.elf
|
||||
@echo
|
||||
@echo '--- making $@ ---'
|
||||
# from the WinAVR makefile template (modified)
|
||||
-$(OBJCOPY) -O $(FORMAT) \
|
||||
-j .eeprom \
|
||||
--set-section-flags=.eeprom="alloc,load" \
|
||||
--change-section-lma .eeprom=0 \
|
||||
--no-change-warnings \
|
||||
'$<' '$@' || exit 0
|
||||
|
||||
%.elf: $(OBJ)
|
||||
@echo
|
||||
@echo '--- making $@ ---'
|
||||
$(CC) $(strip $(CFLAGS)) $(strip $(LDFLAGS)) '$^' --output '$@'
|
||||
|
||||
%.o: %.c
|
||||
@echo
|
||||
@echo '--- making $@ ---'
|
||||
$(CC) -c $(strip $(CFLAGS)) $(strip $(GENDEPFLAGS)) '$<' -o '$@'
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
-include $(OBJ:%=%.dep)
|
||||
|
Loading…
Reference in New Issue