diff options
Diffstat (limited to 'keyboards/ymd75')
-rw-r--r-- | keyboards/ymd75/README.md | 84 | ||||
-rw-r--r-- | keyboards/ymd75/config.h | 1 | ||||
-rw-r--r-- | keyboards/ymd75/i2c.c | 104 | ||||
-rw-r--r-- | keyboards/ymd75/i2c.h | 25 | ||||
-rw-r--r-- | keyboards/ymd75/rules.mk | 20 | ||||
-rw-r--r-- | keyboards/ymd75/usbconfig.h | 12 | ||||
-rw-r--r-- | keyboards/ymd75/ymd75.c | 67 |
7 files changed, 23 insertions, 290 deletions
diff --git a/keyboards/ymd75/README.md b/keyboards/ymd75/README.md index d1c4e95ae7..9a618c5943 100644 --- a/keyboards/ymd75/README.md +++ b/keyboards/ymd75/README.md @@ -1,83 +1,19 @@ -YMD75 / MT84 -========================== +# YMD75 / MT84 -This is a port of the QMK firmware for boards that are based on the -ps2avrGB firmware, like the [ps2avrGB keyboard] (https://www.keyclack.com/product/gb-ps2avrgb/), for use on the YMD75, from YMDK. YMDK sell the board and name it "YMD75", however the PCB has "MT84" printed on both sides. +75% keyboard from YMDK. YMDK sell the board and name it "YMD75", however the PCB has "MT84" printed on both sides. -Most of the code was taken and amended from YMD96 and my port JJ50, which in itself was taken from ps2avrGB and amended by Andrew Novak. - -Note that this is a complete replacement for the firmware, so you won't be -using Bootmapper Client to change any keyboard settings, since not all the -USB report options are supported. - -Hardware Supported: YMD75/MT84 with the ATmega32a chip. -Hardware Availability: The YMD75/MT84 PCB is available from YMDK on AliExpress and suchlike. - -This version by Wayne K Jones (github.com/WarmCatUK) - -## Installing and Building +* Keyboard Maintainer: [Wayne K Jones](github.com/WarmCatUK) +* Hardware Supported: YMD75/MT84 with the ATmega32a chip. +* Hardware Availability: <https://www.aliexpress.com/item/32812690592.html> Make example for this keyboard (after setting up your build environment): -``` -$ make ymd75:default:program -``` -It should detect the keyboard and set it to bootloader mode automatically, prior to flashing firmware. -I've found that I need to remove the previous build/file before making a new one as it doesn't overwrite it; but this might just be my personal experience. - -See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. - -Note that this is a complete replacement for the firmware, so you won't be -using Bootmapper Client to change any keyboard settings, since not all the -USB report options are supported. -In addition you may need the AVR toolchain and `bootloadHID` for flashing: - -``` -$ brew cask install crosspack-avr -$ brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb -``` - -In order to use the `./util/atmega32a_program.py` script, which can reboot the board into -the bootloader, you'll need Python 2 with PyUSB installed: - -``` -$ pip install pyusb -``` - -If you prefer, you can just build it and flash the firmware directly with -`bootloadHID` if you boot the board while holding down `Left Control` to keep it -in the bootloader: - -``` -$ make ymd75 -$ bootloadHID -r ymd75_default.hex -``` -I dont use windows personally, but the following is from ymd96 regarding flashing the atmega32a: - -Since the YMD75/MT84 uses an ATmega32a chip instead of the 32u4, you need to download [HIDBootFlash v.1.0](http://vusb.wikidot.com/project:hidbootflash) for Windows. If anyone knows of a Linux/Mac bootflasher that works, edit this readme! -On Windows, I use [MINGw](http://www.mingw.org/) to compile the keymaps. On Linux or OSX you can simply use the terminal. - -Once you have those two pieces of software: -Build the keyboard with -``` -$ make ymd75:default -``` -If you make your own layout, change the `default` word to whatever your layout is. - -And flash the compiled hex file with `HIDBootFlash`. Simply put the board in flashing mode by plugging it in while holding the key below the top right key, and click `find device`. Then you can specify the .hex file and flash it to the device. - - -## Troubleshooting + make ymd75:default -1. Try plugging the board in while pressing `Backspace` (`Key below the top right key`). This will force it to boot only the bootloader without loading the firmware. Once this is done, just reflash the board with the original firmware. -2. Sometimes USB hubs can act weird, so try connecting the board directly to your computer or plugging/unplugging the USB hub. -3. If you get an error such as "Resource Unavailable" when attemting to flash on Linux, you may want to compile and run `tools/usb_detach.c`. See `tools/README.md` for more info. -4. I was occasionally finding that I wasn't flashing changes that I was making to my keymap. If that happens, remove the previous build and simply force rebuild by making with: -``` -$ rm ymd75_default.hex -$ make -B ymd75:default -$ make -B ymd75:default:program -``` +Flashing example for this keyboard ([after setting up the bootloadHID flashing environment](https://docs.qmk.fm/#/flashing_bootloadhid)) + make ymd75:default:flash +**Reset Key**: Hold down the key located at *Key below the top right key*, commonly programmed as *Backspace* while plugging in the keyboard. +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). diff --git a/keyboards/ymd75/config.h b/keyboards/ymd75/config.h index 6afd077b0a..a56a1b54b8 100644 --- a/keyboards/ymd75/config.h +++ b/keyboards/ymd75/config.h @@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define VENDOR_ID 0x20A0 #define PRODUCT_ID 0x422D +#define DEVICE_VER 0x0200 // TODO: share these strings with usbconfig.h // Edit usbconfig.h to change these. diff --git a/keyboards/ymd75/i2c.c b/keyboards/ymd75/i2c.c deleted file mode 100644 index c27f3e3d17..0000000000 --- a/keyboards/ymd75/i2c.c +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright 2016 Luiz Ribeiro <luizribeiro@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/>. -*/ - -#include <avr/io.h> -#include <util/twi.h> - -#include "i2c.h" - -void i2c_set_bitrate(uint16_t bitrate_khz) { - uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); - if (bitrate_div >= 16) { - bitrate_div = (bitrate_div - 16) / 2; - } - TWBR = bitrate_div; -} - -void i2c_init(void) { - // set pull-up resistors on I2C bus pins - PORTC |= 0b11; - - i2c_set_bitrate(400); - - // enable TWI (two-wire interface) - TWCR |= (1 << TWEN); - - // enable TWI interrupt and slave address ACK - TWCR |= (1 << TWIE); - TWCR |= (1 << TWEA); -} - -uint8_t i2c_start(uint8_t address) { - // reset TWI control register - TWCR = 0; - - // begin transmission and wait for it to end - TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN); - while (!(TWCR & (1<<TWINT))); - - // check if the start condition was successfully transmitted - if ((TWSR & 0xF8) != TW_START) { - return 1; - } - - // transmit address and wait - TWDR = address; - TWCR = (1<<TWINT) | (1<<TWEN); - while (!(TWCR & (1<<TWINT))); - - // check if the device has acknowledged the READ / WRITE mode - uint8_t twst = TW_STATUS & 0xF8; - if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) { - return 1; - } - - return 0; -} - -void i2c_stop(void) { - TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO); -} - -uint8_t i2c_write(uint8_t data) { - TWDR = data; - - // transmit data and wait - TWCR = (1<<TWINT) | (1<<TWEN); - while (!(TWCR & (1<<TWINT))); - - if ((TWSR & 0xF8) != TW_MT_DATA_ACK) { - return 1; - } - - return 0; -} - -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) { - if (i2c_start(address)) { - return 1; - } - - for (uint16_t i = 0; i < length; i++) { - if (i2c_write(data[i])) { - return 1; - } - } - - i2c_stop(); - - return 0; -} diff --git a/keyboards/ymd75/i2c.h b/keyboards/ymd75/i2c.h deleted file mode 100644 index 27c9d3d050..0000000000 --- a/keyboards/ymd75/i2c.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -Copyright 2016 Luiz Ribeiro <luizribeiro@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 __I2C_H__ -#define __I2C_H__ - -void i2c_init(void); -void i2c_set_bitrate(uint16_t bitrate_khz); -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); - -#endif diff --git a/keyboards/ymd75/rules.mk b/keyboards/ymd75/rules.mk index 7bee201738..0c1c9110ca 100644 --- a/keyboards/ymd75/rules.mk +++ b/keyboards/ymd75/rules.mk @@ -1,19 +1,3 @@ -# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> -# Modified 2018 Wayne Jones (WarmCatUK) <waynekjones@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/>. - # MCU name MCU = atmega32a @@ -35,7 +19,7 @@ CONSOLE_ENABLE = no COMMAND_ENABLE = yes BACKLIGHT_ENABLE = yes RGBLIGHT_ENABLE = yes -RGBLIGHT_CUSTOM_DRIVER = yes +WS2812_DRIVER = i2c NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work @@ -51,4 +35,4 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend # custom matrix setup CUSTOM_MATRIX = yes -SRC = matrix.c i2c.c backlight.c +SRC = matrix.c backlight.c diff --git a/keyboards/ymd75/usbconfig.h b/keyboards/ymd75/usbconfig.h index 73afb18e67..0e570b9ec1 100644 --- a/keyboards/ymd75/usbconfig.h +++ b/keyboards/ymd75/usbconfig.h @@ -109,20 +109,10 @@ section at the end of this file). * (e.g. HID), but never want to send any data. This option saves a couple * of bytes in flash memory and the transmit buffers in RAM. */ -#define USB_CFG_INTR_POLL_INTERVAL 1 -/* If you compile a version with endpoint 1 (interrupt-in), this is the poll - * interval. The value is in milliseconds and must not be less than 10 ms for - * low speed devices. - */ #define USB_CFG_IS_SELF_POWERED 0 /* Define this to 1 if the device has its own power supply. Set it to 0 if the * device is powered from the USB bus. */ -#define USB_CFG_MAX_BUS_POWER 500 -/* Set this variable to the maximum USB bus power consumption of your device. - * The value is in milliamperes. [It will be divided by two since USB - * communicates power requirements in units of 2 mA.] - */ #define USB_CFG_IMPLEMENT_FN_WRITE 1 /* Set this to 1 if you want usbFunctionWrite() to be called for control-out * transfers. Set it to 0 if you don't need it and want to save a couple of @@ -238,7 +228,7 @@ section at the end of this file). * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand * the implications! */ -#define USB_CFG_DEVICE_VERSION 0x00, 0x02 +#define USB_CFG_DEVICE_VERSION (DEVICE_VER & 0xFF), ((DEVICE_VER >> 8) & 0xFF) /* Version number of the device: Minor number first, then major number. */ #define USB_CFG_VENDOR_NAME 'Y', 'M', 'D', 'K' diff --git a/keyboards/ymd75/ymd75.c b/keyboards/ymd75/ymd75.c index 2259dfa5f0..74f7c6a493 100644 --- a/keyboards/ymd75/ymd75.c +++ b/keyboards/ymd75/ymd75.c @@ -16,23 +16,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ymd75.h" -//#include "rgblight.h" - -#include <avr/pgmspace.h> - -#include "action_layer.h" -#include "i2c.h" -#include "quantum.h" #include "backlight.h" #include "backlight_custom.h" -// for keyboard subdirectory level init functions -// @Override -void matrix_init_kb(void) { - // call user level keymaps, if any - matrix_init_user(); -} +void matrix_init_kb(void) { matrix_init_user(); } + +__attribute__ ((weak)) +void matrix_init_user(void) {} + +void matrix_scan_kb(void) { matrix_scan_user(); } + +__attribute__ ((weak)) +void matrix_scan_user(void) {} #ifdef BACKLIGHT_ENABLE /// Overrides functions in `quantum.c` @@ -48,48 +44,3 @@ void backlight_set(uint8_t level) { b_led_set(level); } #endif - -#ifdef RGBLIGHT_ENABLE -extern rgblight_config_t rgblight_config; - -// custom RGB driver -void rgblight_set(void) { - if (!rgblight_config.enable) { - for (uint8_t i=0; i<RGBLED_NUM; i++) { - led[i].r = 0; - led[i].g = 0; - led[i].b = 0; - } - } - - i2c_init(); - i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM); -} - -bool rgb_init = false; - -void matrix_scan_kb(void) { - // if LEDs were previously on before poweroff, turn them back on - if (rgb_init == false && rgblight_config.enable) { - i2c_init(); - i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM); - rgb_init = true; - } - - rgblight_task(); -#else - void matrix_scan_kb(void) { -#endif - matrix_scan_user(); - /* Nothing else for now. */ - } - - __attribute__((weak)) // overridable - void matrix_init_user(void) { - - } - - __attribute__((weak)) // overridable - void matrix_scan_user(void) { - - } |