Posted: 21 Apr 2015, 15:34
I can confirm it was the bootmagic build option that cost my firmware to fail on my keyboard. does enabling that require some special sauce? like certain keys should be available or something?
mechanical keyboard authority
http://www.deskthority.net/
Code: Select all
#include "keymap_common.h"
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 0: qwerty */
KEYMAP(
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSLS, GRV, DEL, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSPC, PGUP, \
LCTL, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, PGDN, \
LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, UP, FN1, \
CAPS, LALT, LGUI, FN0, RGUI, RALT, LEFT, DOWN, RGHT),
/* 1: FN1 */
KEYMAP (
TRNS,F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS,TRNS, INS, \
TRNS, HOME ,UP, END,PGUP,TRNS,PGUP,HOME,UP,END,PSCR,SLCK, PAUS,DEL, HOME, \
TRNS, LEFT,DOWN,RGHT,PGDN,TRNS,PGDN,LEFT,DOWN,RIGHT,TRNS,TRNS, TRNS,END, \
TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,TRNS, \
TRNS, TRNS, TRNS, TRNS, TRNS,TRNS,HOME,PGDN,END),
/* 2: alt layout */
KEYMAP (
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSLS, GRV, DEL, \
TAB, Q, P, I, Y, B, V, M, U, L, SCLN, LBRC, RBRC, BSPC, PGUP, \
LCTL, A, N, E, S, F, D, T, H, O, R, QUOT, ENT, PGDN, \
LSFT, COMM, DOT, C, G, SLSH, J, W, K, Z, X, RSFT, UP, FN1, \
CAPS, LALT, LGUI, FN0, RGUI, RALT, LEFT, DOWN, RGHT),
};
const uint16_t PROGMEM fn_actions[] = {
/* Poker Layout */
[0] = ACTION_LAYER_TAP_KEY(1, KC_SPC), // to Fn overlay
[1] = ACTION_LAYER_TOGGLE(2),
};
What would be involved in getting TMK loaded on the Teensy-LC which uses the MKL26Z64VFT4 processor with the Cortex-M0+ core?hasu wrote: TMK also has Cortex-M support now, in fact it works on Infinity(Freescale Kinetis) and I could port PS2-USB converter to NXP LPC11U35. But I didn't try Teensy3.1 yet. TMK uses CMSIS and HAL layer of mbed.org to support the MCU, this means, you are on the shoulders of the giants. Theoretically you can use any MCU mbed.org supports freely like chips from NXP, Freescale, STMicro, Nordic, Renesas. Also you will be able to make use of mbed libraries, code samples and tools.
Meanwhile HaaTa's Kiibohd uses its own concise libraries and PJRC USB stack. You'll be able to grasp its outline and hack it yourself.
Code: Select all
#define KEYMAP( \
K00, K01, K02, K03, K04, K05, K06, K07, \
K10, K12, K13, K14, K15, K16, K17, \
K22, K23, K24, K25, K26, K27, \
K30, K32, K33, K36, K37, \
K40, K42, K43, K45, K47 \
) { \
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
{ KC_##K10, KC_NO, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
{ KC_NO, KC_NO, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \
{ KC_##K30, KC_NO, KC_##K32, KC_##K33, KC_NO, KC_NO, KC_##K36, KC_##K37 }, \
{ KC_##K40, KC_NO, KC_##K42, KC_##K43, KC_NO, KC_##K45, KC_NO, KC_##K47 } \
}
Code: Select all
#include "keymap_common.h"
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/*0: qwerty*/
KEYMAP(1, 2, 3, 4, \
LEFT, RGHT, \
FN1, ENT \
5, 6, 7, 8, \
9, 0, COMM, DOT),
/*1: FN1*/
KEYMAP(F1, F2, F3, F4 \
EQL, MINS,\
TRNS, ENT,\
F5, F6, F7, F8, \
F9, F10, F11, F12),
)
};
const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1),
};
Code: Select all
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* scan matrix
*/
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"
#ifndef DEBOUNCE
# define DEBOUNCE 5
#endif
static uint8_t debouncing = DEBOUNCE;
/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
static matrix_row_t read_cols(void);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);
inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}
inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}
void matrix_init(void)
{
// initialize row and col
unselect_rows();
init_cols();
// initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
matrix[i] = 0;
matrix_debouncing[i] = 0;
}
}
uint8_t matrix_scan(void)
{
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
select_row(i);
_delay_us(30); // without this wait read unstable value.
matrix_row_t cols = read_cols();
if (matrix_debouncing[i] != cols) {
matrix_debouncing[i] = cols;
if (debouncing) {
debug("bounce!: "); debug_hex(debouncing); debug("\n");
}
debouncing = DEBOUNCE;
}
unselect_rows();
}
if (debouncing) {
if (--debouncing) {
_delay_ms(1);
} else {
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix[i] = matrix_debouncing[i];
}
}
}
return 1;
}
bool matrix_is_modified(void)
{
if (debouncing) return false;
return true;
}
inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & ((matrix_row_t)1<<col));
}
inline
matrix_row_t matrix_get_row(uint8_t row)
{
return matrix[row];
}
void matrix_print(void)
{
print("\nr/c 0123456789ABCDEF\n");
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
phex(row); print(": ");
pbin_reverse16(matrix_get_row(row));
print("\n");
}
}
uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop16(matrix[i]);
}
return count;
}
/* Column pin configuration
* col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
* pin: F5 F4 F1 F0 C6 B6 D4 B1 B0 B5 B4 D7 D6 B3 (Rev.A)
* pin: B7 (Rev.B)
*/
static void init_cols(void)
{
// Input with pull-up(DDR:0, PORT:1)
DDRF &= ~(1<<5 | 1<<4 | 1<<1 | 1<<0);
PORTF |= (1<<5 | 1<<4 | 1<<1 | 1<<0);
}
static matrix_row_t read_cols(void)
{
return (PINF&(1<<5) ? 0 : (1<<0)) |
(PINF&(1<<4) ? 0 : (1<<1)) |
(PINE&(1<<1) ? 0 : (1<<2)) |
(PINC&(1<<0) ? 0 : (1<<3)) |
(PINC&(1<<6) ? 0 : (1<<4)) |
(PINB&(1<<6) ? 0 : (1<<5)) |
(PIND&(1<<4) ? 0 : (1<<6)) |
(PINB&(1<<1) ? 0 : (1<<7)) |
((PINB&(1<<0) && PINB&(1<<7)) ? 0 : (1<<8)) | // Rev.A and B
(PINB&(1<<5) ? 0 : (1<<9)) |
(PINB&(1<<4) ? 0 : (1<<10)) |
(PIND&(1<<7) ? 0 : (1<<11)) |
(PIND&(1<<6) ? 0 : (1<<12)) |
(PINB&(1<<3) ? 0 : (1<<13));
}
/* Row pin configuration
* row: 0 1 2 3 4
* pin: D0 D1 D2 D3 D5
*/
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
DDRD &= ~0b00101111;
PORTD &= ~0b00101111;
}
static void select_row(uint8_t row)
{
// Output low(DDR:1, PORT:0) to select
switch (row) {
case 0:
DDRC |= (1<<6);
PORTC &= ~(1<<6);
break;
case 1:
DDRD |= (1<<3);
PORTD &= ~(1<<3);
break;
case 2:
DDRD |= (1<<2);
PORTD &= ~(1<<2);
break;
case 3:
DDRD |= (1<<1);
PORTD &= ~(1<<1);
break;
case 4:
DDRD |= (1<<0);
PORTD &= ~(1<<0);
break;
}
}
Code: Select all
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIG_H
#define CONFIG_H
/* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6060
#define DEVICE_VER 0x0001
#define MANUFACTURER geekhack
#define PRODUCT GH60
#define DESCRIPTION t.m.k. keyboard firmware for GH60
/* key matrix size */
#define MATRIX_ROWS 5
#define MATRIX_COLS 4
/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST
/* Set 0 if debouncing isn't needed */
#define DEBOUNCE 5
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)
/*
* Feature disable options
* These options are also useful to firmware size reduction.
*/
/* disable debug print */
//#define NO_DEBUG
/* disable print */
//#define NO_PRINT
/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION
#endif
I would think that compilers can deal with this kind of problems. Also - the first complaint about fork is actually _before_ the compiler runs (before ---begin---). But you may be right.
Code: Select all
// Hi-Z(DDR:0, PORT:0) to unselect
DDRD &= ~0b00001111;
PORTD &= ~0b00001111;
DDRC &= ~0b01000000;
PORTC &= ~0b01000000;
Oh, good point. I didn't read the output very carefully but it does indeed look like the error is from Make, not the compiler. So I agree - try to compile the firmware without any changes first.