diff --git a/keyboards/cheapino/cheapino.c b/keyboards/cheapino/cheapino.c new file mode 100644 index 0000000000..5ab224c7d2 --- /dev/null +++ b/keyboards/cheapino/cheapino.c @@ -0,0 +1,15 @@ +#include +#include +#include "quantum.h" +#include QMK_KEYBOARD_H +#include "i2c_master.h" + + +void keyboard_post_init_user(void) { + // Customise these values to desired behaviour + debug_enable=true; + //debug_matrix=true; + debug_keyboard=true; + //debug_mouse=true; +} + diff --git a/keyboards/cheapino/config.h b/keyboards/cheapino/config.h new file mode 100644 index 0000000000..f18ed7cd9d --- /dev/null +++ b/keyboards/cheapino/config.h @@ -0,0 +1,27 @@ +// Copyright 2022 Thomas Haukland (@Thomas Haukland) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "config_common.h" + +/* + * 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 I2C_DRIVER I2CD2 +#define I2C1_SCL_PIN GP3 +#define I2C1_SDA_PIN GP2 + diff --git a/keyboards/cheapino/halconf.h b/keyboards/cheapino/halconf.h new file mode 100644 index 0000000000..c06a0cbf6c --- /dev/null +++ b/keyboards/cheapino/halconf.h @@ -0,0 +1,8 @@ + +#pragma once + +#define HAL_USE_PWM TRUE +#define HAL_USE_PAL TRUE +#define HAL_USE_I2C TRUE + +#include_next diff --git a/keyboards/cheapino/info.json b/keyboards/cheapino/info.json new file mode 100644 index 0000000000..ca51c3f1f8 --- /dev/null +++ b/keyboards/cheapino/info.json @@ -0,0 +1,36 @@ +{ + "manufacturer": "Thomas Haukland", + "keyboard_name": "cheapino", + "maintainer": "Thomas Haukland", + "bootloader": "rp2040", + "diode_direction": "COL2ROW", + "features": { + "bootmagic": true, + "command": false, + "console": true, + "extrakey": true, + "mousekey": true, + "nkro": true + }, + "matrix_pins": { + "cols": ["GP2", "GP2"], + "rows": ["GP1", "GP1"] + }, + "processor": "RP2040", + "url": "", + "usb": { + "device_version": "1.0.0", + "pid": "0x0000", + "vid": "0xFEED" + }, + "layouts": { + "LAYOUT_ortho_2x2": { + "layout": [ + { "matrix": [0, 0], "x": 0, "y": 0 }, + { "matrix": [0, 1], "x": 1, "y": 0 }, + { "matrix": [1, 0], "x": 0, "y": 1 }, + { "matrix": [1, 1], "x": 1, "y": 1 } + ] + } + } +} diff --git a/keyboards/cheapino/keymaps/default/keymap.c b/keyboards/cheapino/keymaps/default/keymap.c new file mode 100644 index 0000000000..795c0d0e10 --- /dev/null +++ b/keyboards/cheapino/keymaps/default/keymap.c @@ -0,0 +1,15 @@ +#include QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* + * ┌───┬───┬───┐ + * │ A │ B │ C │ + * ├───┼───┼───┤ + * │ D │ E │ F │ + * └───┴───┴───┘ + */ + [0] = LAYOUT_ortho_2x2( + KC_A, KC_B, + KC_C, KC_D + ) +}; diff --git a/keyboards/cheapino/matrix.c b/keyboards/cheapino/matrix.c new file mode 100644 index 0000000000..e5197ee564 --- /dev/null +++ b/keyboards/cheapino/matrix.c @@ -0,0 +1,103 @@ +#include +#include +#include "quantum.h" +#include QMK_KEYBOARD_H +#include "i2c_master.h" +#include + + +bool i2c_initialized = 0; +i2c_status_t i2c_status; +#define LED_COUNT 4 +const uint8_t leds[LED_COUNT] = {GP7,GP8,GP15,GP14}; +bool led_status[LED_COUNT] = {true,true,true,true}; +uint8_t _buf; + + /* matrix state(1:on, 0:off) */ + //static matrix_row_t matrix[MATRIX_ROWS]; // debounced values + +// The PCF857 addresses are explained on page 9 here: +// https://www.ti.com/lit/ds/symlink/pcf8574.pdf +// On the Cheapino, A0-A2 are grounded for a 0 value +// In arduino, PCF857 address is 0x20, but thats without +// the read/write bit at the end, so including that(unset) +// the address is here 0x20 << 1 = 0b01000000 +//uint16_t i2c_timeout = 1250; +#define I2C_ADDR 0b01000000 +#define I2C_ADDR_WRITE 0b01000000 +#define I2C_ADDR_READ 0b01000001 +//#define I2C_TIMEOUT 1000 + +void toggle_leds(void) { + for (int i = 0; i < LED_COUNT; i++) + { + writePin(leds[i], led_status[i] ? 1 : 0); + } +} +void matrix_init_custom(void) { + //setPinOutput(GP6); + //writePinHigh(GP6); + printf("Init Cheapino!\n"); + + if (i2c_initialized == 0) { + i2c_init(); + i2c_initialized = true; + wait_ms(I2C_TIMEOUT); + } + for (int i=0; i + +#undef RP_I2C_USE_I2C1 +#define RP_I2C_USE_I2C1 TRUE diff --git a/keyboards/cheapino/readme.md b/keyboards/cheapino/readme.md new file mode 100644 index 0000000000..39867b5aaf --- /dev/null +++ b/keyboards/cheapino/readme.md @@ -0,0 +1,27 @@ +# cheapino + +![cheapino](imgur.com image replace me!) + +*A short description of the keyboard/project* + +* Keyboard Maintainer: [Thomas Haukland](https://github.com/Thomas Haukland) +* Hardware Supported: *The PCBs, controllers supported* +* Hardware Availability: *Links to where you can find this hardware* + +Make example for this keyboard (after setting up your build environment): + + make cheapino:default + +Flashing example for this keyboard: + + make cheapino:default:flash + +See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). + +## Bootloader + +Enter the bootloader in 3 ways: + +* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard +* **Physical reset button**: Briefly press the button on the back of the PCB - some may have pads you must short instead +* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available diff --git a/keyboards/cheapino/rules.mk b/keyboards/cheapino/rules.mk new file mode 100644 index 0000000000..be7e38e4f9 --- /dev/null +++ b/keyboards/cheapino/rules.mk @@ -0,0 +1,4 @@ +# This file intentionally left blank +CUSTOM_MATRIX = lite +QUANTUM_LIB_SRC += i2c_master.c +SRC += matrix.c