Skip to content

Commit

Permalink
fix eeprom bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaxin96 committed Jun 14, 2021
1 parent 21e2df3 commit cf46f1e
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 54 deletions.
21 changes: 0 additions & 21 deletions keyboards/yandrstudio/whiteMouse28T/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,4 @@



/* RGN Matrix */
#ifdef RGB_MATRIX_ENABLE

# define RGB_DI_PIN B5
# define RGBLED_NUM 2
# define DRIVER_LED_TOTAL RGBLED_NUM


# define WS2812_SPI SPID1 // default: SPID1
# define WS2812_SPI_MOSI_PAL_MODE 5

# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 180
# define RGBLIGHT_VAL_STEP 18
# define RGB_DISABLE_WHEN_USB_SUSPENDED true
# define RGB_MATRIX_CENTER { 32, 96 }
# define RGB_MATRIX_KEYPRESSES
# define RGB_MATRIX_FRAMEBUFFER_EFFECTS

#endif



34 changes: 34 additions & 0 deletions keyboards/yandrstudio/whiteMouse28T/f401/chconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* Copyright 2020 QMK
*
* 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:https://www.gnu.org/licenses/>.
*/

#pragma once

#define CH_CFG_ST_FREQUENCY 10000

#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE

#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE

#define CH_CFG_FACTORY_SEMAPHORES TRUE

#define CH_CFG_FACTORY_MAILBOXES TRUE

#define CH_CFG_FACTORY_OBJ_FIFOS TRUE

#define CH_CFG_FACTORY_PIPES TRUE

#include_next <chconf.h>

94 changes: 94 additions & 0 deletions keyboards/yandrstudio/whiteMouse28T/f401/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/* Copyright 2021 JasonRen(biu)
*
* 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:https://www.gnu.org/licenses/>.
*/
#pragma once

#include "config_common.h"


/* RGN Matrix */
#ifdef RGB_MATRIX_ENABLE

# define RGB_DI_PIN B5
# define RGBLED_NUM 1
# define DRIVER_LED_TOTAL RGBLED_NUM

#define WS2812_PWM_DRIVER PWMD3 // default: PWMD2
#define WS2812_PWM_CHANNEL 2 // default: 2
#define WS2812_PWM_PAL_MODE 2 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 2
#define WS2812_DMA_STREAM STM32_DMA1_STREAM2 // DMA Stream for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
#define WS2812_DMA_CHANNEL 5 // DMA Channel for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.

# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 100
# define RGBLIGHT_VAL_STEP 18
# define RGB_DISABLE_WHEN_USB_SUSPENDED true
# define RGB_MATRIX_CENTER { 32, 96 }
# define RGB_MATRIX_KEYPRESSES
# define RGB_MATRIX_FRAMEBUFFER_EFFECTS

// # define WS2812_EXTERNAL_PULLUP
# define WS2812_BYTE_ORDER WS2812_BYTE_ORDER_RGB
#endif


#ifdef RGBLIGHT_ENABLE

# define RGB_DI_PIN B5
# define RGBLED_NUM 1
# define DRIVER_LED_TOTAL RGBLED_NUM


#define WS2812_PWM_DRIVER PWMD3 // default: PWMD2
#define WS2812_PWM_CHANNEL 2 // default: 2
#define WS2812_PWM_PAL_MODE 2 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 2
#define WS2812_DMA_STREAM STM32_DMA1_STREAM2 // DMA Stream for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
#define WS2812_DMA_CHANNEL 5 // DMA Channel for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.


// # define WS2812_EXTERNAL_PULLUP
# define WS2812_BYTE_ORDER WS2812_BYTE_ORDER_RGB

#endif

#ifdef EEPROM_SPI

# define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN A4
# define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 3
# define EXTERNAL_EEPROM_BYTE_COUNT 32768
# define EXTERNAL_EEPROM_PAGE_SIZE 64
# define EXTERNAL_EEPROM_ADDRESS_SIZE 2


# define SPI_DRIVER SPID1
# define SPI_SCK_PIN A5
# define SPI_MOSI_PIN A7
# define SPI_MISO_PIN A6

# ifdef VIA_ENABLE
# define VIA_EEPROM_LAYOUT_OPTIONS_SIZE 2
# define DYNAMIC_KEYMAP_LAYER_COUNT 20
# define DYNAMIC_KEYMAP_MACRO_COUNT 30
# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 10240
# endif

#else

# define TRANSIENT_EEPROM_SIZE 1024

#endif

// #define DEBUG_MATRIX_SCAN_RATE


9 changes: 6 additions & 3 deletions keyboards/yandrstudio/whiteMouse28T/f401/halconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#pragma once
#include_next <halconf.h>

// #undef HAL_USE_PWM
// #define HAL_USE_PWM TRUE
#undef HAL_USE_PWM
#define HAL_USE_PWM TRUE

// #define HAL_USE_SERIAL TRUE

Expand All @@ -30,5 +30,8 @@
#undef HAL_USE_SPI
#define HAL_USE_SPI TRUE


#undef SPI_USE_WAIT
#define SPI_USE_WAIT TRUE
#undef SPI_SELECT_MODE
#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD

9 changes: 7 additions & 2 deletions keyboards/yandrstudio/whiteMouse28T/f401/mcuconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@

#include_next <mcuconf.h>

#undef STM32_SPI_USE_SPI1
#define STM32_SPI_USE_SPI1 TRUE
#undef STM32_PWM_USE_TIM3
#define STM32_PWM_USE_TIM3 TRUE


#undef STM32_SPI_USE_SPI1
#define STM32_SPI_USE_SPI1 TRUE

#undef STM32_NO_INIT
#undef STM32_HSI_ENABLED
Expand Down Expand Up @@ -63,8 +65,11 @@
#define STM32_PLLN_VALUE 192
#define STM32_PLLP_VALUE 4
#define STM32_PLLQ_VALUE 4
// AHB prescaler value.
#define STM32_HPRE STM32_HPRE_DIV1
//APB1 prescaler value.
#define STM32_PPRE1 STM32_PPRE1_DIV4
//APB2 prescaler value.
#define STM32_PPRE2 STM32_PPRE2_DIV2
#define STM32_RTCSEL STM32_RTCSEL_LSI
#define STM32_RTCPRE_VALUE 8
Expand Down
8 changes: 8 additions & 0 deletions keyboards/yandrstudio/whiteMouse28T/f401/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ MCU = STM32F401
# Address of the bootloader in system memory
STM32_BOOTLOADER_ADDRESS = 0x1FFF0000

# Bootloader selection
BOOTLOADER = stm32-dfu


CUSTOM_MATRIX = lite # for using the A9 pin as matrix io

# # project specific file
QUANTUM_SRC += matrix.c


WS2812_DRIVER = pwm

# EEPROM_DRIVER = spi
6 changes: 0 additions & 6 deletions keyboards/yandrstudio/whiteMouse28T/info-via.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@
"0,6"
],
[
{
"f": 1
},
"1,0",
{
"f": 3
},
"1,1",
"1,2",
"1,3",
Expand Down
3 changes: 1 addition & 2 deletions keyboards/yandrstudio/whiteMouse28T/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y,
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H,
KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RALT, KC_TRNS, KC_RCTL)

RGB_TOG, KC_LALT, KC_LGUI, KC_SPC, KC_RALT, KC_TRNS, KC_RCTL)
};
27 changes: 24 additions & 3 deletions keyboards/yandrstudio/whiteMouse28T/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,35 @@


const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
LAYOUT(
LAYOUT(
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y,
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, MO(1), KC_RSFT),
RGB_TOG, KC_Z, KC_X, KC_C, KC_V, MO(1), KC_RSFT),
LAYOUT(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
LAYOUT(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
LAYOUT(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
};


// void keyboard_post_init_user(void) {
// eeconfig_init();
// // Customise these values to desired behaviour
// // debug_enable=true;
// // debug_matrix=false;
// // debug_keyboard=true;
// //debug_mouse=true;
// }

10 changes: 6 additions & 4 deletions keyboards/yandrstudio/whiteMouse28T/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
# change yes to no to disable
#
BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration
# KEYBOARD_SHARED_EP = yes # Free up some extra endpoints - needed if console+mouse+extra
MOUSEKEY_ENABLE = no # Mouse keys
KEYBOARD_SHARED_EP = yes # Free up some extra endpoints - needed if console+mouse+extra
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = no # Console for debug
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
NKRO_ENABLE = yes # USB Nkey Rollover
RGB_MATRIX_ENABLE = yes
RGB_MATRIX_DRIVER = WS2812
WS2812_DRIVER = spi

# RGBLIGHT_ENABLE = yes
# RGBLIGHT_DRIVER = WS2812

26 changes: 13 additions & 13 deletions keyboards/yandrstudio/whiteMouse28T/whiteMouse28T.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@
#ifdef RGB_MATRIX_ENABLE
led_config_t g_led_config = {
{
{ 0, 1, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, \
{ NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, \
{ NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, \
{ NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, \
{ NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, 0 }, \
},
{
// LED Index to Physical Position
{0, 0}, {16, 0}
{0, 0}

},
{
// LED Index to Flag
4, 4
4
}
};

Expand All @@ -50,14 +50,14 @@ led_config_t g_led_config = {

#endif

#ifdef RGB_DISABLE_WHEN_USB_SUSPENDED
void suspend_power_down_kb(void) {
rgb_matrix_set_suspend_state(true);
suspend_power_down_user();
}
// #ifdef RGB_DISABLE_WHEN_USB_SUSPENDED
// void suspend_power_down_kb(void) {
// rgb_matrix_set_suspend_state(true);
// suspend_power_down_user();
// }

void suspend_wakeup_init_kb(void) {
rgb_matrix_set_suspend_state(false);
suspend_wakeup_init_user();
}
#endif
// void suspend_wakeup_init_kb(void) {
// rgb_matrix_set_suspend_state(false);
// suspend_wakeup_init_user();
// }
// #endif

0 comments on commit cf46f1e

Please sign in to comment.