How to build your very own keyboard firmware

I do not use Atmel's MCU to design my keyboard,I use the STC15W4K32S MCU.So,can I use the QMK firmware?How should I alter it?My programme's ability is very very bad.Who can help me?The STC15W4K32S is 89C51 series's MCU.
Antaliess

Unread post08 Sep 2018, 03:28

X
Antaliess
 
Posts: 1
Joined: 08 Sep 2018, 03:11
Location: China
Main keyboard: xd75,amj60,cospad,xd96,staryu
Main mouse: anker
Favorite switch: red
DT Pro Member: -
 
Antaliess wrote:So, can I use the QMK firmware? How should I alter it?My programme's ability is very very bad. Who can help me? The STC15W4K32S is 89C51 series's MCU.

TMK and QMK support AVR MCUs and some ARM MCUs via ChibiOS.
I can't find any specs of STC15W4K32S, but you say that it is compatible with Atmel 89C51. It's a different architecture (Intel 8051) and it has only 4KB of internal flash which makes it impossible to port QMK on it even if you have the required exprerience.
Quartz64
User avatar

Unread post11 Sep 2018, 15:17

User avatar
X
Quartz64
 
Posts: 37
Joined: 16 Jan 2018, 12:04
Location: Russua
Main keyboard: Ergodox (Gateron blue)
Main mouse: Kensington Orbit Scroll trackball
Favorite switch: Gateron blue
DT Pro Member: -
 
Location: China
Main keyboard: xd75,amj60,cospad,xd96,staryu

Are you from kprepublic? :lol:
scottc
User avatar

Unread post11 Sep 2018, 22:44

User avatar
X
scottc
 
Posts: 5672
Joined: 06 Oct 2013, 21:09
Location: Remote locations in Europe
Main keyboard: GH60-HASRO 62g Nixies, HHKB Pro1 HS, Novatouch
Main mouse: Steelseries Rival 300
Favorite switch: Nixdorf 'Soft Touch' MX Black
DT Pro Member: -
 
Hi, can some help with the layering. The file compiles if I don't put anything in the PROGMEM fn_actions function. But if I try to add some layer action. I get the same 4 errors on each line

warning: (near initialization for 'fn_action[0]')
error: field name not in record or union initializer
error:(near initialization for 'fn_action[0]')
warning: braces around scalar initializer

I don't know if anything is wrong with the code inside the function, because I pretty much just copy pasted it.
{
[0] = ACTION_LAYER_TOGGLE(0),
[1] = ACTION_LAYER_TOGGLE(1),
[2] = ACTION_LAYER_TOGGLE(2)
};
DettolGlen20

Unread post23 Sep 2018, 08:12

X
DettolGlen20
 
Posts: 1
Joined: 23 Sep 2018, 08:03
Location: Australia
DT Pro Member: -
 
hi, I need help to solve this error
Attachments
Captura de pantalla (15).png
scorpion

Unread post29 Nov 2018, 03:48

X
scorpion
 
Posts: 1
Joined: 29 Nov 2018, 03:42
Location: Chile
Main keyboard: generic
Main mouse: logitech G pro
Favorite switch: red
DT Pro Member: -
 
scorpion wrote:hi, I need help to solve this error

maybe this has some information: https://github.com/tmk/tmk_keyboard/issues/378
Slom

Unread post29 Nov 2018, 05:44

X
Slom
 
Posts: 771
Joined: 10 Jan 2014, 17:00
Location: land of the rusty beamsprings
DT Pro Member: -
 
Okay, so I've been working on the code for a numpad project I've been doing for a while now and I finished. I've compiled everything and ran the firmware properly. My only issue that it seems like my code is either totally incorrect or I did my wiring improperly. Only the key I assigned as PAUS works and it writes the whole row that is above it. I'm a total newbie and this is the first time I do anything related to coding so expect a lot of dumb mistakes. UPDATE So I've fixed an issue that I had in the matrix coding and now I'm sure it's all correct. My issue is, the same key I mentioned earlier functions and nothing else does. I think my issue is wiring, does anyone else think the same?
Spoiler:
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

Spoiler:
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);


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;
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

/* Column pin configuration
 * col: 0   1   2   3   4   5   6   7   8   9   10  11  12  13
 * pin: F0  F1  E6  C7  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<<0 | 1<<4 | 1<<5 | 1<<6);
    PORTF |=  (1<<0 | 1<<4 | 1<<5 | 1<<6);

}

static matrix_row_t read_cols(void)
{
    return (PINF&(1<<0) ? 0 : (1<<0)) |
           (PINF&(1<<4) ? 0 : (1<<1)) |
           (PINF&(1<<5) ? 0 : (1<<2)) |
           (PINF&(1<<6) ? 0 : (1<<3));
}

/* 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
    DDRB  &= ~0b01001111;
    PORTB &= ~0b01001111;
}

static void select_row(uint8_t row)
{
    // Output low(DDR:1, PORT:0) to select
    switch (row) {
        case 0:
            DDRB  |= (1<<7);
            PORTB &= ~(1<<7);
            break;
        case 1:
            DDRB  |= (1<<3);
            PORTB &= ~(1<<3);
            break;
        case 2:
            DDRB  |= (1<<2);
            PORTB &= ~(1<<2);
            break;
        case 3:
            DDRB  |= (1<<1);
            PORTB &= ~(1<<1);
            break;
        case 4:
            DDRB  |= (1<<0);
            PORTB &= ~(1<<0);
            break;
    }
}

Spoiler:
Code: Select all
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
   KEYMAP(ESC, SLSH, BSPC, MINS, \
         7, 8, 9, PAUS, \
         4, 5, 6, \
         1, 2, 3, ENTER, \
         0, DOT),
};
const action_t PROGMEM fn_actions[] = {
           };

Spoiler:
Code: Select all
/*
Copyright 2012,2013 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 KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h"
#include "debug.h"
#include "keymap.h"


/* GH60 keymap definition macro
 * K2C, K31 and  K3C are extra keys for ISO
 */
#define KEYMAP( \
    K00, K01, K02, K03, \
    K10, K11, K12, K13, \
    K20, K21, K22, \
    K30, K31, K32, K33, \
    K41, K42 \
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03 }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13 }, \
    { KC_##K20, KC_##K21, KC_##K22, KC_NO }, \
    { KC_##K30, KC_##K31, KC_##K32, KC_##K33 }, \
    { KC_NO, KC_##K41, KC_##K42, KC_NO }  \
}

/* ANSI variant. No extra keys for ISO */
#define KEYMAP_ANSI( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,      K2D, \
    K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B,           K3D, \
    K40, K41, K42,           K45,                     K4A, K4B, K4C, K4D  \
) KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, NO,  K2D, \
    K30, NO,  K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, NO,  K3D, \
    K40, K41, K42,           K45,                NO,  K4A, K4B, K4C, K4D  \
)


#define KEYMAP_HHKB( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K49,\
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,      K2D, \
    K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B,      K3D, K3C, \
    K40, K41, K42,           K45,                     K4A, K4B, K4C, K4D  \
) KEYMAP( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, NO,  K2D, \
    K30, NO,  K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \
    K40, K41, K42,           K45,                K49, K4A, K4B, K4C, K4D  \
)

#endif
fuuifu

Unread post03 Dec 2018, 10:51

X
fuuifu
 
Posts: 2
Joined: 24 Nov 2018, 06:32
Location: United Arab Emirates
DT Pro Member: -
 
Took me a while to figure out, BUT I DID IT! I noticed I had my diodes flipped, so I flipped them back. My code was totally fine haha.
fuuifu

Unread post03 Dec 2018, 15:57

X
fuuifu
 
Posts: 2
Joined: 24 Nov 2018, 06:32
Location: United Arab Emirates
DT Pro Member: -
 
Previous

Who is online

Users browsing this forum: anthonymak, Dilettant and 44 guests