Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Y&R Studio zhou65 keyboard #14192

Merged
merged 41 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
bc37cfc
add yr kbs
jiaxin96 Aug 27, 2021
c673215
Delete uchen80v1.zip
jiaxin96 Aug 27, 2021
d645f0a
add zhou65
jiaxin96 Aug 27, 2021
10e3453
Update keyboards/yandrstudio/zhou65/config.h
jiaxin96 Aug 29, 2021
a67fa4a
Update keyboards/yandrstudio/zhou65/zhou65.c
jiaxin96 Aug 29, 2021
6245858
Update zhou65.c
jiaxin96 Aug 29, 2021
d694429
Update matrix.c
jiaxin96 Aug 29, 2021
4e36a33
Update matrix.c
jiaxin96 Aug 29, 2021
3103299
Update zhou65.c
jiaxin96 Aug 29, 2021
3aa79f7
Temporarily delete eep support and wait for qmk main branch developme…
jiaxin96 Aug 29, 2021
0bfe362
Delete special matrix configuration files for A9 pin
jiaxin96 Aug 29, 2021
35c3b52
fix keymap layer 1
jiaxin96 Aug 29, 2021
42692e3
set KC_LSFT 2 KC_RSFT in right hand part keymap
jiaxin96 Aug 29, 2021
68ceaae
add yr kbs
jiaxin96 Aug 27, 2021
a8394cc
Delete uchen80v1.zip
jiaxin96 Aug 27, 2021
ac74851
add zhou65
jiaxin96 Aug 27, 2021
7b9b337
Update keyboards/yandrstudio/zhou65/config.h
jiaxin96 Aug 29, 2021
485152e
Update keyboards/yandrstudio/zhou65/zhou65.c
jiaxin96 Aug 29, 2021
cafe05a
Update zhou65.c
jiaxin96 Aug 29, 2021
77210fd
Update matrix.c
jiaxin96 Aug 29, 2021
00c4aeb
Update matrix.c
jiaxin96 Aug 29, 2021
eecef20
Update zhou65.c
jiaxin96 Aug 29, 2021
39c1449
Temporarily delete eep support and wait for qmk main branch developme…
jiaxin96 Aug 29, 2021
e689cdd
Delete special matrix configuration files for A9 pin
jiaxin96 Aug 29, 2021
b80b053
fix keymap layer 1
jiaxin96 Aug 29, 2021
e1aed89
set KC_LSFT 2 KC_RSFT in right hand part keymap
jiaxin96 Aug 29, 2021
8613b9a
Merge branch 'zhou65' of https://github.com/Oh-My-Mechanical-Keyboard…
jiaxin96 Aug 30, 2021
f1f12b0
rebase
jiaxin96 Aug 30, 2021
6464ad9
Revert "rebase"
jiaxin96 Aug 30, 2021
e934ef0
Update keyboards/yandrstudio/zhou65/readme.md
jiaxin96 Nov 19, 2021
fd04253
Update keyboards/yandrstudio/zhou65/readme.md
jiaxin96 Nov 19, 2021
5a97828
Update readme.md
jiaxin96 Nov 19, 2021
8c28109
Update readme.md
jiaxin96 Nov 19, 2021
2d7b8f1
Update rules.mk
jiaxin96 Nov 23, 2021
01fb2b2
Update config.h
jiaxin96 Nov 23, 2021
2c0538e
Update config.h
jiaxin96 Nov 23, 2021
f81bc0c
Update keyboards/yandrstudio/zhou65/f401/board.h
jiaxin96 Feb 22, 2022
bd0ee6a
Delete chconf.h
jiaxin96 Feb 22, 2022
f27586b
Update keyboards/yandrstudio/zhou65/rules.mk
jiaxin96 Feb 28, 2022
75652e7
Update keyboards/yandrstudio/zhou65/info.json
jiaxin96 Feb 28, 2022
d51e35a
Update keyboards/yandrstudio/zhou65/rules.mk
jiaxin96 Mar 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions keyboards/yandrstudio/zhou65/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* 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://www.gnu.org/licenses/>.
*/
#pragma once

#include "config_common.h"

/* USB Device descriptor parameter */
#define VENDOR_ID 0xAA96
#define PRODUCT_ID 0xAAAD
#define DEVICE_VER 0x0001
#define MANUFACTURER lkaill-Y&R
#define PRODUCT zhou65
#define DESCRIPTION STM32 based 65%.
jiaxin96 marked this conversation as resolved.
Show resolved Hide resolved

/* enable the nkro when using the VIA. */
#define FORCE_NKRO

/* fix VIA RGB_light */
#define VIA_HAS_BROKEN_KEYCODES


/* Set 0 if debouncing isn't needed */
#define DEBOUNCE 1

#define USB_POLLING_INTERVAL_MS 1
#define QMK_KEYS_PER_SCAN 4
25 changes: 25 additions & 0 deletions keyboards/yandrstudio/zhou65/f401/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* Copyright 2020 Nick Brassel (tzarc)
*
* 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 3 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 <https://www.gnu.org/licenses/>.
*/
#pragma once

#include_next "board.h"


#undef STM32_HSECLK
#define STM32_HSECLK 8000000


#define BOARD_UCHEN_F401
jiaxin96 marked this conversation as resolved.
Show resolved Hide resolved
34 changes: 34 additions & 0 deletions keyboards/yandrstudio/zhou65/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://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
jiaxin96 marked this conversation as resolved.
Show resolved Hide resolved

#include_next <chconf.h>

33 changes: 33 additions & 0 deletions keyboards/yandrstudio/zhou65/f401/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* 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://www.gnu.org/licenses/>.
*/
#pragma once

#include "config_common.h"

/* key matrix size */
#define MATRIX_ROWS 5
#define MATRIX_COLS 15

/* key matrix pins */
#define MATRIX_ROW_PINS { A2, A1, B8, B7, C15 }
#define MATRIX_COL_PINS { B9, B6, B5, B4, B3, B1, B0, A7, A6, A5, A4, A3, A8, B15, B14 }

/* COL2ROW or ROW2COL */
#define DIODE_DIRECTION ROW2COL

#define LED_CAPS_LOCK_PIN A15
#define LED_PIN_ON_STATE 0

217 changes: 217 additions & 0 deletions keyboards/yandrstudio/zhou65/f401/eep/eeprom_stm32.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
/*
* This software is experimental and a work in progress.
* Under no circumstances should these files be used in relation to any critical system(s).
* Use of these files is at your own risk.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* This files are free to use from http://engsta.com/stm32-flash-memory-eeprom-emulator/ by
* Artur F.
*
* Modifications for QMK and STM32F303 by Yiancar
* update for STM32F4 support and the the flashing algorithm by yulei
* Adjust the file structure to custom EEPROM_DRIVER by jiaxin96 for support stm32f401cc
*/

#include <stdio.h>
#include <string.h>
#include "eeprom_stm32_custom.h"
#include "eeprom_driver.h"
/*****************************************************************************
* Allows to use the internal flash to store non volatile data. To initialize
* the functionality use the EEPROM_Init() function. Be sure that by reprogramming
* of the controller just affected pages will be deleted. In other case the non
* volatile data will be lost.
******************************************************************************/

/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Functions -----------------------------------------------------------------*/

#define IS_VALID_ADDRESS(x) ((x) < FEE_MAX_BYTES)

uint8_t DataBuf[FEE_MAX_BYTES];
static void EEPROM_Backup(void);
static FLASH_Status EEPROM_Restore(void);
static uint32_t EEPROM_FindValidAddress(void);
static void EEPROM_Clear(void);

/*****************************************************************************
* Unlock the FLASH programming and initialized the DataBuf
******************************************************************************/
uint16_t EEPROM_Init(void) {
// unlock flash
FLASH_Unlock();

// initialize DataBuf
EEPROM_Backup();

// Clear Flags
// FLASH_ClearFlag(FLASH_SR_EOP|FLASH_SR_PGERR|FLASH_SR_WRPERR);

return FEE_DENSITY_BYTES;
}
void eeprom_driver_init(void) {
EEPROM_Init();
}

/*****************************************************************************
* Erase the whole reserved Flash Space used for user Data
******************************************************************************/
void EEPROM_Erase(void) {
// erase all flash pages
EEPROM_Clear();

// reset the content of the buffer
memset(&DataBuf[0], FEE_EMPTY_BYTE, sizeof(DataBuf));
}
void eeprom_driver_erase(void) {
EEPROM_Erase();
}
/*****************************************************************************
* Write data with its eeprom address to flash if there has empty words,
* otherwise backup the current valid data, erase all flash pages,
* and finally restore the valid data.
*******************************************************************************/
uint16_t EEPROM_WriteDataByte(uint16_t Address, uint8_t DataByte) {
FLASH_Status FlashStatus = FLASH_COMPLETE;

uint32_t addr;
// exit if not a valid address
if (!IS_VALID_ADDRESS(Address)) {
return 0;
}

// we are sure the address will not be out of bound
#pragma GCC diagnostic ignored "-Warray-bounds"
// same value, do not need program
if (DataBuf[Address] == DataByte) {
return FlashStatus;
}

// find the address can be written
addr = EEPROM_FindValidAddress();
DataBuf[Address] = DataByte;
#pragma GCC diagnostic pop
if (addr == FEE_EMPTY_VALUE) {
// EEPROM is full, need to erase and reprogramming
EEPROM_Clear();
EEPROM_Restore();
} else {
FLASH_ProgramHalfWord(FEE_ADDR_ADDRESS(addr), Address);
FLASH_ProgramHalfWord(FEE_DATA_ADDRESS(addr), DataByte);
}

return FlashStatus;
}
/*****************************************************************************
* Read once data byte from a specified address.
*******************************************************************************/
uint8_t EEPROM_ReadDataByte(uint16_t Address) {
if (!IS_VALID_ADDRESS(Address)) {
return FEE_EMPTY_BYTE;
}

// Get Byte from caches
return DataBuf[Address];
}

/*****************************************************************************
* helper functions
*******************************************************************************/
// backup the current data
void EEPROM_Backup(void)
{
uint32_t begin = FEE_PAGE_BASE_ADDRESS;
uint32_t end = FEE_PAGE_END_ADDRESS;
memset(&DataBuf[0], FEE_EMPTY_BYTE, sizeof(DataBuf));
while( begin < end) {
uint16_t addr = *(__IO uint16_t*)(FEE_ADDR_ADDRESS(begin));
if (IS_VALID_ADDRESS(addr)) {
DataBuf[addr] = *(__IO uint16_t*)(FEE_DATA_ADDRESS(begin));
} else if( addr == FEE_EMPTY_WORD) {
uint16_t data = *(__IO uint16_t*)(FEE_DATA_ADDRESS(begin));
if (data == FEE_EMPTY_WORD) {
// we reached the end of valid data
break;
}
}
begin += 4;
}
}
// restore data from DataBuf
FLASH_Status EEPROM_Restore(void) {
uint32_t cur = FEE_PAGE_BASE_ADDRESS;
for (uint8_t i = 0; i < FEE_MAX_BYTES; i++) {
if (DataBuf[i] != FEE_EMPTY_BYTE) {
FLASH_ProgramHalfWord(FEE_ADDR_ADDRESS(cur), i);
FLASH_ProgramHalfWord(FEE_DATA_ADDRESS(cur), DataBuf[i]);
cur += 4;
}
}
return FLASH_COMPLETE;
}
// find an empty place for programming
uint32_t EEPROM_FindValidAddress(void) {
uint32_t begin = FEE_PAGE_BASE_ADDRESS;
uint32_t end = FEE_PAGE_END_ADDRESS;
while( begin < end) {
uint32_t data = *(__IO uint32_t*)(begin);
if (data == FEE_EMPTY_VALUE) {
return begin;
}
begin += 4;
}
return FEE_EMPTY_VALUE;
}

void EEPROM_Clear(void)
{
#if defined(EEPROM_EMU_STM32F401xC)
FLASH_ErasePage(FEE_SECTOR_ID);
#else
int page_num = 0;

// delete all pages from specified start page to the last page
do {
FLASH_ErasePage(FEE_PAGE_BASE_ADDRESS + (page_num * FEE_PAGE_SIZE));
page_num++;
} while (page_num < FEE_DENSITY_PAGES);
#endif
}
/*****************************************************************************
* Wrap library in AVR style functions.
*******************************************************************************/
uint8_t eeprom_read_byte_f4(const uint8_t *Address) {
const uint16_t p = (const uint32_t)Address;
return EEPROM_ReadDataByte(p);
}

void eeprom_write_byte_f4(uint8_t *Address, uint8_t Value) {
uint16_t p = (uint32_t)Address;
EEPROM_WriteDataByte(p, Value);
}


void eeprom_read_block(void *buf, const void *addr, size_t len) {
const uint8_t *p = (const uint8_t *)addr;
uint8_t * dest = (uint8_t *)buf;
while (len--) {
*dest++ = eeprom_read_byte_f4(p++);
}
}

void eeprom_write_block(const void *buf, void *addr, size_t len) {
uint8_t * p = (uint8_t *)addr;
const uint8_t *src = (const uint8_t *)buf;
while (len--) {
eeprom_write_byte_f4(p++, *src++);
}
}


Loading