cleaned up a bunch and worked on the makefile; now compiling! :D
parent
f47ab1315e
commit
0774d0dd09
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.dep
|
||||
|
||||
*.eep
|
||||
*.elf
|
||||
*.hex
|
||||
*.map
|
|
@ -22,7 +22,7 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
|
||||
uint8_t teensy__init (void);
|
||||
uint8_t teensy__update_matrix (bool matrix[OPT__KB__ROWS][OPT__KB__COLUMNS])
|
||||
uint8_t teensy__update_matrix (bool matrix[OPT__KB__ROWS][OPT__KB__COLUMNS]);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -27,6 +27,57 @@
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/** macros/P/description
|
||||
* Expand `name` into the corresponding "press" function name
|
||||
*/
|
||||
#define P(name) keys__press__##name
|
||||
|
||||
/** macros/R/description
|
||||
* Expand `name` into the corresponding "release" function name
|
||||
*/
|
||||
#define R(name) keys__release__##name
|
||||
|
||||
/** macros/K/description
|
||||
* Expand into a "key" suitable for putting into the layout matrix
|
||||
*/
|
||||
#define K(name) { &P(name), &R(name) }
|
||||
|
||||
/** macros/KF/description
|
||||
* Expand `name` into the corresponding "key_functions" function name
|
||||
*/
|
||||
#define KF(name) key_functions__##name
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// special meaning keys (may be used by `exec_key()`)
|
||||
|
||||
/** keys/transp/description
|
||||
* transparent
|
||||
*
|
||||
* This key signals to the firmware (specifically the
|
||||
* `kb__layout__exec_key_location()` function) that it should look for what key
|
||||
* to "press" or "release" by going down the layer-stack until it finds a
|
||||
* non-transparent key at the same position.
|
||||
*
|
||||
* Notes:
|
||||
* - With this scheme, keys may be half transparent; that is, the "press" part
|
||||
* of a key may be transparent while the "release" part isn't, or vice versa.
|
||||
* I expect this to be fairly uncommon though.
|
||||
*/
|
||||
void KF(transp) (void) {}
|
||||
#define keys__press__transp KF(transp)
|
||||
#define keys__release__transp KF(transp)
|
||||
|
||||
/** keys/nop/desctiption
|
||||
* no operation
|
||||
*
|
||||
* This key does nothing (and is not transparent).
|
||||
*/
|
||||
void KF(nop) (void) {}
|
||||
#define keys__press__nop KF(nop)
|
||||
#define keys__release__nop KF(nop)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/** typedefs/key_t/description
|
||||
* The type we will use for our "key"s
|
||||
*
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void kb__layout__exec_key(bool pressed, int8_t row, int8_t column) {
|
||||
void kb__layout__exec_key(bool pressed, uint8_t row, uint8_t column) {
|
||||
void (*function)(void);
|
||||
|
||||
for(uint8_t i=0; i<layer_stack__size(); i++) {
|
||||
|
@ -29,6 +29,10 @@ void kb__layout__exec_key(bool pressed, int8_t row, int8_t column) {
|
|||
[ row ]
|
||||
[ column ]
|
||||
[ (pressed) ? 0 : 1 ];
|
||||
|
||||
if (function == &KF(transp))
|
||||
function = NULL;
|
||||
|
||||
if (function) {
|
||||
(*function)();
|
||||
|
||||
|
|
|
@ -37,28 +37,6 @@
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/** macros/P/description
|
||||
* Expand `name` into the corresponding "press" function name
|
||||
*/
|
||||
#define P(name) keys__press__##name
|
||||
|
||||
/** macros/R/description
|
||||
* Expand `name` into the corresponding "release" function name
|
||||
*/
|
||||
#define R(name) keys__release__##name
|
||||
|
||||
/** macros/K/description
|
||||
* Expand into a "key" suitable for putting into the layout matrix
|
||||
*/
|
||||
#define K(name) { &P(name), &R(name) }
|
||||
|
||||
/** macros/KF/description
|
||||
* Expand `name` into the corresponding "key_functions" function name
|
||||
*/
|
||||
#define KF(name) key_functions__##name
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/** macros/KEYS__DEFAULT/description
|
||||
* Define the functions for a default key (i.e. a normal key that presses and
|
||||
* releases a keycode as you'd expect)
|
||||
|
@ -110,13 +88,13 @@
|
|||
* from above):
|
||||
*
|
||||
* #define keys__press__lpu1l1 P(lpupo1l1)
|
||||
* #define keys__release__lpu1l1 P(nop)
|
||||
* #define keys__release__lpu1l1 KF(nop)
|
||||
* #define keys__press__lpo1l1 R(lpupo1l1)
|
||||
* #define keys__release__lpo1l1 P(nop)
|
||||
* #define keys__release__lpo1l1 KF(nop)
|
||||
*/
|
||||
#define KEYS__LAYER__PUSH_POP(ID, LAYER) \
|
||||
void P(l##ID##pupo##LAYER) (void) { layer_stack__push(ID, LAYER); } \
|
||||
void R(l##ID##pupo##LAYER) (void) { layer_stack__pop_id(ID); }
|
||||
void P(lpupo##ID##l##LAYER) (void) { layer_stack__push(0, ID, LAYER); } \
|
||||
void R(lpupo##ID##l##LAYER) (void) { layer_stack__pop_id(ID); }
|
||||
|
||||
/** macros/(group) layer : number pad/description
|
||||
* Define function for pushing and popping the number pad (namely `numPush`,
|
||||
|
@ -131,7 +109,7 @@
|
|||
* they need to know the layer on which the number pad has been placed.
|
||||
*/
|
||||
#define KEYS__LAYER__NUM_PU_PO(ID, LAYER) \
|
||||
void P(numPuPo) (void) { layer_stack__push(ID, LAYER); \
|
||||
void P(numPuPo) (void) { layer_stack__push(0, ID, LAYER); \
|
||||
KF(press)(KEYBOARD__LockingNumLock); \
|
||||
usb__kb__send_report(); \
|
||||
KF(release)(KEYBOARD__LockingNumLock); \
|
||||
|
@ -142,12 +120,12 @@
|
|||
KF(release)(KEYBOARD__LockingNumLock); \
|
||||
usb__kb__send_report(); }
|
||||
|
||||
#define KEYS__LAYER__NUM_PUSH(LAYER, ID) \
|
||||
void P(numPush) (void) { layer_stack__push(ID, LAYER); \
|
||||
#define KEYS__LAYER__NUM_PUSH(ID, LAYER) \
|
||||
void P(numPush) (void) { layer_stack__push(0, ID, LAYER); \
|
||||
KF(press)(KEYBOARD__LockingNumLock); } \
|
||||
void R(numPush) (void) { KF(release)(KEYBOARD__LockingNumLock); }
|
||||
|
||||
#define KEYS__LAYER__NUM_POP(LAYER, ID) \
|
||||
#define KEYS__LAYER__NUM_POP(ID) \
|
||||
void P(numPop) (void) { layer_stack__pop_id(ID); \
|
||||
KF(press)(KEYBOARD__LockingNumLock); } \
|
||||
void R(numPop) (void) { KF(release)(KEYBOARD__LockingNumLock); }
|
||||
|
@ -161,7 +139,7 @@
|
|||
* Meant to be used with the left and right "shift" keys.
|
||||
*/
|
||||
void KF(2_keys_capslock)(bool pressed, uint8_t keycode) {
|
||||
static counter = 0;
|
||||
static uint8_t counter = 0;
|
||||
if (pressed) {
|
||||
counter++;
|
||||
KF(press)(keycode);
|
||||
|
@ -179,34 +157,7 @@ void KF(2_keys_capslock)(bool pressed, uint8_t keycode) {
|
|||
|
||||
// --- default key definitions ------------------------------------------------
|
||||
|
||||
#include "../../../../firmware/lib/layout/keys.h"
|
||||
|
||||
|
||||
// --- special meaning --------------------------------------------------------
|
||||
|
||||
/** keys/transp/description
|
||||
* transparent
|
||||
*
|
||||
* This key signals to the firmware (specifically the
|
||||
* `kb__layout__exec_key_location()` function) that it should look for what key
|
||||
* to "press" or "release" by going down the layer-stack until it finds a
|
||||
* non-transparent key at the same position.
|
||||
*
|
||||
* Notes:
|
||||
* - With this scheme, keys may be half transparent; that is, the "press" part
|
||||
* of a key may be transparent while the "release" part isn't, or vice versa.
|
||||
* I expect this to be fairly uncommon though.
|
||||
*/
|
||||
#define keys__press__transp NULL
|
||||
#define keys__release__transp NULL
|
||||
|
||||
/** keys/nop/desctiption
|
||||
* no operation
|
||||
*
|
||||
* This key does nothing (and is not transparent).
|
||||
*/
|
||||
void P(nop) (void) {}
|
||||
void R(nop) (void) {}
|
||||
#include "../../../../../firmware/lib/layout/keys.h"
|
||||
|
||||
|
||||
// --- special keycode --------------------------------------------------------
|
||||
|
@ -256,63 +207,63 @@ void R(btldr) (void) {}
|
|||
|
||||
KEYS__LAYER__PUSH_POP(0, 0);
|
||||
#define keys__press__lpu0l0 P(lpupo0l0)
|
||||
#define keys__release__lpu0l0 P(nop)
|
||||
#define keys__release__lpu0l0 KF(nop)
|
||||
#define keys__press__lpo0l0 R(lpupo0l0)
|
||||
#define keys__release__lpo0l0 P(nop)
|
||||
#define keys__release__lpo0l0 KF(nop)
|
||||
|
||||
KEYS__LAYER__PUSH_POP(1, 1);
|
||||
#define keys__press__lpu1l1 P(lpupo1l1)
|
||||
#define keys__release__lpu1l1 P(nop)
|
||||
#define keys__press__lpu1l1 R(lpupo1l1)
|
||||
#define keys__release__lpu1l1 KF(nop)
|
||||
#define keys__press__lpo1l1 R(lpupo1l1)
|
||||
#define keys__release__lpo1l1 P(nop)
|
||||
#define keys__release__lpo1l1 KF(nop)
|
||||
|
||||
KEYS__LAYER__PUSH_POP(2, 2);
|
||||
#define keys__press__lpu2l2 P(lpupo2l2)
|
||||
#define keys__release__lpu2l2 P(nop)
|
||||
#define keys__release__lpu2l2 KF(nop)
|
||||
#define keys__press__lpo2l2 R(lpupo2l2)
|
||||
#define keys__release__lpo2l2 P(nop)
|
||||
#define keys__release__lpo2l2 KF(nop)
|
||||
|
||||
KEYS__LAYER__PUSH_POP(3, 3);
|
||||
#define keys__press__lpu3l3 P(lpupo3l3)
|
||||
#define keys__release__lpu3l3 P(nop)
|
||||
#define keys__release__lpu3l3 KF(nop)
|
||||
#define keys__press__lpo3l3 R(lpupo3l3)
|
||||
#define keys__release__lpo3l3 P(nop)
|
||||
#define keys__release__lpo3l3 KF(nop)
|
||||
|
||||
KEYS__LAYER__PUSH_POP(4, 4);
|
||||
#define keys__press__lpu4l4 P(lpupo4l4)
|
||||
#define keys__release__lpu4l4 P(nop)
|
||||
#define keys__release__lpu4l4 KF(nop)
|
||||
#define keys__press__lpo4l4 R(lpupo4l4)
|
||||
#define keys__release__lpo4l4 P(nop)
|
||||
#define keys__release__lpo4l4 KF(nop)
|
||||
|
||||
KEYS__LAYER__PUSH_POP(5, 5);
|
||||
#define keys__press__lpu5l5 P(lpupo5l5)
|
||||
#define keys__release__lpu5l5 P(nop)
|
||||
#define keys__release__lpu5l5 KF(nop)
|
||||
#define keys__press__lpo5l5 R(lpupo5l5)
|
||||
#define keys__release__lpo5l5 P(nop)
|
||||
#define keys__release__lpo5l5 KF(nop)
|
||||
|
||||
KEYS__LAYER__PUSH_POP(6, 6);
|
||||
#define keys__press__lpu6l6 P(lpupo6l6)
|
||||
#define keys__release__lpu6l6 P(nop)
|
||||
#define keys__release__lpu6l6 KF(nop)
|
||||
#define keys__press__lpo6l6 R(lpupo6l6)
|
||||
#define keys__release__lpo6l6 P(nop)
|
||||
#define keys__release__lpo6l6 KF(nop)
|
||||
|
||||
KEYS__LAYER__PUSH_POP(7, 7);
|
||||
#define keys__press__lpu7l7 P(lpupo7l7)
|
||||
#define keys__release__lpu7l7 P(nop)
|
||||
#define keys__release__lpu7l7 KF(nop)
|
||||
#define keys__press__lpo7l7 R(lpupo7l7)
|
||||
#define keys__release__lpo7l7 P(nop)
|
||||
#define keys__release__lpo7l7 KF(nop)
|
||||
|
||||
KEYS__LAYER__PUSH_POP(8, 8);
|
||||
#define keys__press__lpu8l8 P(lpupo8l8)
|
||||
#define keys__release__lpu8l8 P(nop)
|
||||
#define keys__release__lpu8l8 KF(nop)
|
||||
#define keys__press__lpo8l8 R(lpupo8l8)
|
||||
#define keys__release__lpo8l8 P(nop)
|
||||
#define keys__release__lpo8l8 KF(nop)
|
||||
|
||||
KEYS__LAYER__PUSH_POP(9, 9);
|
||||
#define keys__press__lpu9l9 P(lpupo9l9)
|
||||
#define keys__release__lpu9l9 P(nop)
|
||||
#define keys__release__lpu9l9 KF(nop)
|
||||
#define keys__press__lpo9l9 R(lpupo9l9)
|
||||
#define keys__release__lpo9l9 P(nop)
|
||||
#define keys__release__lpo9l9 KF(nop)
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
@ -63,9 +64,10 @@ bool kb__led__read(uint8_t 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;
|
||||
case 4: ;
|
||||
case 5: ;
|
||||
};
|
||||
return false;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define OPT__TWI__FREQENCY 400000
|
||||
#define OPT__TWI__FREQUENCY 400000
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -11,26 +11,6 @@
|
|||
#
|
||||
|
||||
|
||||
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
|
||||
# the binary format to generate
|
||||
|
||||
|
@ -52,9 +32,31 @@ KEYBOARD_LAYOUTS := \
|
|||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SCR += $(wildcard $(CURDIR)/*.c)
|
||||
CURDIRS := $(CURDIR) $(CURDIRS)
|
||||
# -------
|
||||
CURDIR := $(ROOTDIR)/lib/twi
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(ROOTDIR)/lib/usb
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(ROOTDIR)/lib/layout/eeprom-macro
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(ROOTDIR)/lib/layout/key-functions
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(ROOTDIR)/lib/layout/layer-stack
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(firstword $(CURDIRS))
|
||||
CURDIRS := $(wordlist 2,$(words $(CURDIRS)),$(CURDIRS))
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SRC += $(wildcard $(CURDIR)/*.c)
|
||||
SRC += $(wildcard $(CURDIR)/controller/*.c)
|
||||
SRC += $(wildcard $(CURDIR)/layout/$(KEYBOARD_LAYOUT)*.c)
|
||||
|
||||
CFLAGS += -include '$(wildcard $(CURDIR)/options.h)'
|
||||
CFLAGS += -include $(wildcard $(CURDIR)/options.h)
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
// from PJRC (slightly modified)
|
||||
// <http://www.pjrc.com/teensy/jump_to_bootloader.html>
|
||||
void kf__jump_to_bootloader (uint16_t ignore) {
|
||||
void key_functions__jump_to_bootloader (uint16_t ignore) {
|
||||
// --- for all Teensy boards ---
|
||||
|
||||
cli();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void kf__toggle_capslock (uint16_t ignore) {
|
||||
void key_functions__toggle_capslock (uint16_t ignore) {
|
||||
|
||||
// save the state of left and right shift
|
||||
bool lshift_pressed = usb__kb__read_key(KEYBOARD__LeftShift);
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void twi_init(void) {
|
||||
void twi__init(void) {
|
||||
// set the prescaler value to 0
|
||||
TWSR &= ~( (1<<TWPS1)|(1<<TWPS0) );
|
||||
// set the bit rate
|
||||
|
@ -49,7 +49,7 @@ void twi_init(void) {
|
|||
TWBR = ((F_CPU / OPT__TWI__FREQUENCY) - 16) / 2;
|
||||
}
|
||||
|
||||
uint8_t twi_start(void) {
|
||||
uint8_t twi__start(void) {
|
||||
// send start
|
||||
TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWSTA);
|
||||
// wait for transmission to complete
|
||||
|
@ -61,14 +61,14 @@ uint8_t twi_start(void) {
|
|||
return 0; // success
|
||||
}
|
||||
|
||||
void twi_stop(void) {
|
||||
void twi__stop(void) {
|
||||
// send stop
|
||||
TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWSTO);
|
||||
// wait for transmission to complete
|
||||
while (TWCR & (1<<TWSTO));
|
||||
}
|
||||
|
||||
uint8_t twi_send(uint8_t data) {
|
||||
uint8_t twi__send(uint8_t data) {
|
||||
// load data into the data register
|
||||
TWDR = data;
|
||||
// send data
|
||||
|
@ -83,7 +83,7 @@ uint8_t twi_send(uint8_t data) {
|
|||
return 0; // success
|
||||
}
|
||||
|
||||
uint8_t twi_read(uint8_t * data) {
|
||||
uint8_t twi__read(uint8_t * data) {
|
||||
// read 1 byte to TWDR, send ACK
|
||||
TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWEA);
|
||||
// wait for transmission to complete
|
||||
|
@ -96,8 +96,3 @@ uint8_t twi_read(uint8_t * data) {
|
|||
return 0; // success
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
#endif
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
* This is currently a wrapper for the PJRC code
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "./keyboard/from-pjrc/usb_keyboard.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "./usage-page/keyboard.h"
|
||||
#include "../usage-page/keyboard.h"
|
||||
#include "./keyboard/from-pjrc/usb_keyboard.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
* - 'description' added
|
||||
* - `usb_keyboard_press()` removed
|
||||
* - `OPT__` macros added (and other code modified accordingly)
|
||||
* - `PROGMEM` code made `const`
|
||||
*/
|
||||
|
||||
|
||||
|
@ -130,7 +131,7 @@ static const uint8_t PROGMEM endpoint_config_table[] = {
|
|||
// spec and relevant portions of any USB class specifications!
|
||||
|
||||
|
||||
static uint8_t PROGMEM device_descriptor[] = {
|
||||
static const uint8_t PROGMEM device_descriptor[] = {
|
||||
18, // bLength
|
||||
1, // bDescriptorType
|
||||
0x00, 0x02, // bcdUSB
|
||||
|
@ -148,7 +149,7 @@ static uint8_t PROGMEM device_descriptor[] = {
|
|||
};
|
||||
|
||||
// Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
|
||||
static uint8_t PROGMEM keyboard_hid_report_desc[] = {
|
||||
static const uint8_t PROGMEM keyboard_hid_report_desc[] = {
|
||||
0x05, 0x01, // Usage Page (Generic Desktop),
|
||||
0x09, 0x06, // Usage (Keyboard),
|
||||
0xA1, 0x01, // Collection (Application),
|
||||
|
@ -185,7 +186,7 @@ static uint8_t PROGMEM keyboard_hid_report_desc[] = {
|
|||
|
||||
#define CONFIG1_DESC_SIZE (9+9+9+7)
|
||||
#define KEYBOARD_HID_DESC_OFFSET (9+9)
|
||||
static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
|
||||
static const uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
|
||||
// configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
|
||||
9, // bLength;
|
||||
2, // bDescriptorType;
|
||||
|
@ -232,17 +233,17 @@ struct usb_string_descriptor_struct {
|
|||
uint8_t bDescriptorType;
|
||||
int16_t wString[];
|
||||
};
|
||||
static struct usb_string_descriptor_struct PROGMEM string0 = {
|
||||
static const struct usb_string_descriptor_struct PROGMEM string0 = {
|
||||
4,
|
||||
3,
|
||||
{0x0409}
|
||||
};
|
||||
static struct usb_string_descriptor_struct PROGMEM string1 = {
|
||||
static const struct usb_string_descriptor_struct PROGMEM string1 = {
|
||||
sizeof(STR_MANUFACTURER),
|
||||
3,
|
||||
STR_MANUFACTURER
|
||||
};
|
||||
static struct usb_string_descriptor_struct PROGMEM string2 = {
|
||||
static const struct usb_string_descriptor_struct PROGMEM string2 = {
|
||||
sizeof(STR_PRODUCT),
|
||||
3,
|
||||
STR_PRODUCT
|
||||
|
@ -250,7 +251,7 @@ static struct usb_string_descriptor_struct PROGMEM string2 = {
|
|||
|
||||
// This table defines which descriptor data is sent for each specific
|
||||
// request from the host (in wValue and wIndex).
|
||||
static struct descriptor_list_struct {
|
||||
static const struct descriptor_list_struct {
|
||||
uint16_t wValue;
|
||||
uint16_t wIndex;
|
||||
const uint8_t *addr;
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <util/delay.h>
|
||||
#include "../firmware/keyboard.h"
|
||||
#include "../firmware/lib/usb.h"
|
||||
#include "./main.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -29,13 +31,6 @@
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../firmware/keyboard.h"
|
||||
#include "../firmware/lib/usb.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define main__is_pressed is_pressed
|
||||
#define main__was_pressed was_pressed
|
||||
#define main__row row
|
||||
|
@ -64,15 +59,17 @@ uint8_t col;
|
|||
* look through the source, especially the documentation, to see how things are
|
||||
* defined and what's actually happening.
|
||||
*/
|
||||
void main(void) {
|
||||
int main(void) {
|
||||
static bool (*temp)[OPT__KB__ROWS][OPT__KB__COLUMNS]; // for swapping below
|
||||
static bool key_is_pressed;
|
||||
static bool key_was_pressed;
|
||||
|
||||
kb__init(); // initialize hardware (besides USB)
|
||||
|
||||
kb__led__state__power_on();
|
||||
|
||||
usb__init();
|
||||
while (!usb__configured());
|
||||
while (!usb__is_configured());
|
||||
kb__led__delay__usb_init(); // give the OS time to load drivers, etc.
|
||||
|
||||
kb__led__state__ready();
|
||||
|
@ -112,5 +109,7 @@ void main(void) {
|
|||
#undef on
|
||||
#undef off
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,6 @@
|
|||
# [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
|
||||
|
@ -31,13 +26,29 @@ KEYBOARD_NAME := ergodox
|
|||
TARGET := firmware
|
||||
# default name for the '.hex', '.eep', and '.map' files we'll be generating
|
||||
|
||||
OLD_CURDIR := $(CURDIR)
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
CURDIR := .
|
||||
ROOTDIR := .
|
||||
# note: by default, `CURDIR` is initialized to (an absolute path to) the
|
||||
# current working directory
|
||||
|
||||
SRC :=
|
||||
CFLAGS :=
|
||||
LDFLAGS :=
|
||||
GENDEPFLAGS :=
|
||||
# (initialize the variables so we can use `+=` below and in the included files)
|
||||
|
||||
CURDIRS := $(CURDIR) $(CURDIRS)
|
||||
# -------
|
||||
CURDIR := $(CURDIR)/keyboard/$(KEYBOARD_NAME)
|
||||
CURDIR := $(ROOTDIR)/keyboard/$(KEYBOARD_NAME)
|
||||
include $(CURDIR)/options.mk
|
||||
# (the place for everything a keyboard implementation might want to change)
|
||||
# -------
|
||||
CURDIR := $(OLD_CURDIR)
|
||||
CURDIR := $(firstword $(CURDIRS))
|
||||
CURDIRS := $(wordlist 2,$(words $(CURDIRS)),$(CURDIRS))
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
SRC += $(wildcard $(CURDIR)/main.c)
|
||||
# (other source files included through the makefile included above)
|
||||
|
@ -66,13 +77,13 @@ CFLAGS += -fdata-sections # / section in the output file if the
|
|||
# unused code.
|
||||
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
LDFLAGS := -Wl,-Map=$(TARGET).map,--cref # generate a link map, with a cross
|
||||
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
|
||||
GENDEPFLAGS += -MMD -MP -MF $@.dep # generate dependency files
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
@ -82,7 +93,7 @@ SIZE := avr-size
|
|||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
OBJ = $(SRC:%.c=%.o)
|
||||
OBJ := $(SRC:%.c=%.o)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
@ -95,9 +106,9 @@ all: $(TARGET).hex $(TARGET).eep
|
|||
@echo '---------------------------------------------------------------'
|
||||
@echo '------- done --------------------------------------------------'
|
||||
@echo
|
||||
$(SIZE) --target=$(FORMAT) $(TARGET).hex
|
||||
$(SIZE) --target=$(BINARY_FORMAT) $(TARGET).hex
|
||||
@echo
|
||||
$(SIZE) --target=$(FORMAT) $(TARGET).eep
|
||||
$(SIZE) --target=$(BINARY_FORMAT) $(TARGET).eep
|
||||
@echo
|
||||
@echo 'you can load "$(TARGET).hex" and "$(TARGET).eep" onto the'
|
||||
@echo 'Teensy using the Teensy loader'
|
||||
|
@ -118,30 +129,30 @@ clean:
|
|||
@echo
|
||||
@echo '--- making $@ ---'
|
||||
# from the WinAVR makefile template (modified)
|
||||
$(OBJCOPY) -O $(FORMAT) \
|
||||
$(OBJCOPY) -O $(BINARY_FORMAT) \
|
||||
-R .eeprom -R .fuse -R .lock -R .signature \
|
||||
'$<' '$@'
|
||||
$< $@
|
||||
|
||||
%.eep: %.elf
|
||||
@echo
|
||||
@echo '--- making $@ ---'
|
||||
# from the WinAVR makefile template (modified)
|
||||
-$(OBJCOPY) -O $(FORMAT) \
|
||||
-$(OBJCOPY) -O $(BINARY_FORMAT) \
|
||||
-j .eeprom \
|
||||
--set-section-flags=.eeprom="alloc,load" \
|
||||
--change-section-lma .eeprom=0 \
|
||||
--no-change-warnings \
|
||||
'$<' '$@' || exit 0
|
||||
$< $@ || exit 0
|
||||
|
||||
$(TARGET).elf: $(OBJ)
|
||||
@echo
|
||||
@echo '--- making $@ ---'
|
||||
$(CC) $(strip $(CFLAGS)) $(strip $(LDFLAGS)) '$^' --output '$@'
|
||||
$(CC) $(strip $(CFLAGS)) $(strip $(LDFLAGS)) $^ --output $@
|
||||
|
||||
%.o: %.c
|
||||
@echo
|
||||
@echo '--- making $@ ---'
|
||||
$(CC) -c $(strip $(CFLAGS)) $(strip $(GENDEPFLAGS)) '$<' -o '$@'
|
||||
$(CC) -c $(strip $(CFLAGS)) $(strip $(GENDEPFLAGS)) $< -o $@
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue