Skip to content

Commit ddd97c6

Browse files
committed
[Keyboard] Add Nuphy Air96 v2 keyboard
1 parent f63faa9 commit ddd97c6

15 files changed

Lines changed: 3757 additions & 0 deletions

File tree

keyboards/nuphy/air96_v2/ansi/ansi.c

Lines changed: 755 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
/*
2+
Copyright 2023 @ Nuphy <https://nuphy.com/>
3+
4+
This program is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 2 of the License, or
7+
(at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#pragma once
19+
20+
#include "quantum.h"
21+
22+
enum custom_keycodes {
23+
RF_DFU = QK_KB_0,
24+
LNK_USB,
25+
LNK_RF,
26+
LNK_BLE1,
27+
LNK_BLE2,
28+
LNK_BLE3,
29+
30+
MAC_TASK,
31+
MAC_SEARCH,
32+
MAC_VOICE,
33+
MAC_CONSOLE,
34+
MAC_DND,
35+
MAC_PRT,
36+
MAC_PRTA,
37+
38+
SIDE_VAI,
39+
SIDE_VAD,
40+
SIDE_MOD,
41+
SIDE_HUI,
42+
SIDE_SPI,
43+
SIDE_SPD,
44+
45+
DEV_RESET,
46+
SLEEP_MODE,
47+
BAT_SHOW,
48+
RGB_TEST,
49+
BAT_NUM
50+
};
51+
52+
53+
typedef enum {
54+
RX_Idle,
55+
RX_Receiving,
56+
RX_Done,
57+
RX_Fail,
58+
RX_OV_ERR,
59+
RX_SUM_ERR,
60+
RX_CMD_ERR,
61+
RX_DATA_ERR,
62+
RX_DATA_OV,
63+
RX_FORMAT_ERR,
64+
65+
TX_OK = 0XE0,
66+
TX_DONE,
67+
TX_BUSY,
68+
TX_TIMEOUT,
69+
TX_DATA_ERR,
70+
71+
} TYPE_RX_STATE;
72+
73+
#define FUNC_VALID_LEN 32
74+
75+
#define RF_IDLE 0
76+
#define RF_PAIRING 1
77+
#define RF_LINKING 2
78+
#define RF_CONNECT 3
79+
#define RF_DISCONNECT 4
80+
#define RF_SLEEP 5
81+
#define RF_SNIF 6
82+
#define RF_INVAILD 0XFE
83+
#define RF_ERR_STATE 0XFF
84+
85+
86+
#define CMD_POWER_UP 0XF0
87+
#define CMD_SLEEP 0XF1
88+
#define CMD_HAND 0XF2
89+
#define CMD_SNIF 0XF3
90+
#define CMD_24G_SUSPEND 0XF4
91+
#define CMD_IDLE_EXIT 0XFE
92+
93+
#define CMD_RPT_MS 0XE0
94+
#define CMD_RPT_BYTE_KB 0XE1
95+
#define CMD_RPT_BIT_KB 0XE2
96+
#define CMD_RPT_CONSUME 0XE3
97+
#define CMD_RPT_SYS 0XE4
98+
99+
#define CMD_SET_LINK 0XC0
100+
#define CMD_SET_CONFIG 0XC1
101+
#define CMD_GET_CONFIG 0XC2
102+
#define CMD_SET_NAME 0XC3
103+
#define CMD_GET_NAME 0XC4
104+
#define CMD_CLR_DEVICE 0XC5
105+
#define CMD_NEW_ADV 0XC7
106+
#define CMD_RF_STS_SYSC 0XC9
107+
#define CMD_SET_24G_NAME 0XCA
108+
#define CMD_GO_TEST 0XCF
109+
110+
#define CMD_RF_DFU 0XB1
111+
112+
#define CMD_WRITE_DATA 0X80
113+
#define CMD_READ_DATA 0X81
114+
115+
#define LINK_RF_24 0
116+
#define LINK_BT_1 1
117+
#define LINK_BT_2 2
118+
#define LINK_BT_3 3
119+
#define LINK_USB 4
120+
121+
#define UART_MAX_LEN 64
122+
typedef struct
123+
{
124+
uint8_t RXDState;
125+
uint8_t RXDLen;
126+
uint8_t RXDOverTime;
127+
uint8_t TXDLenBack;
128+
uint8_t TXDOffset;
129+
uint8_t TXDBuf[UART_MAX_LEN];
130+
uint8_t RXDBuf[UART_MAX_LEN];
131+
} USART_MGR_STRUCT;
132+
133+
typedef struct
134+
{
135+
uint8_t link_mode;
136+
uint8_t rf_channel;
137+
uint8_t ble_channel;
138+
uint8_t rf_state;
139+
uint8_t rf_charge;
140+
uint8_t rf_led;
141+
uint8_t rf_baterry;
142+
uint8_t sys_sw_state;
143+
} DEV_INFO_STRUCT;
144+
145+
146+
#define SYS_SW_WIN 0xa1
147+
#define SYS_SW_MAC 0xa2
148+
149+
#define RF_LINK_SHOW_TIME 300
150+
151+
#define HOST_USB_TYPE 0
152+
#define HOST_BLE_TYPE 1
153+
#define HOST_RF_TYPE 2
154+
155+
#define LINK_TIMEOUT (uint16_t)(100 * 120)
156+
#define SLEEP_TIME_DELAY (uint16_t)(100 * 360)
157+
#define POWER_DOWN_DELAY (uint16_t)(24)
158+
159+
typedef struct
160+
{
161+
uint8_t default_brightness_flag;
162+
uint8_t ee_side_mode;
163+
uint8_t ee_side_light;
164+
uint8_t ee_side_speed;
165+
uint8_t ee_side_rgb;
166+
uint8_t ee_side_colour;
167+
uint8_t sleep_enable;
168+
uint8_t retain2;
169+
} user_config_t;
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
Copyright 2023 @ Nuphy <https://nuphy.com/>
3+
4+
This program is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 2 of the License, or
7+
(at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#pragma once
19+
20+
#define TAP_CODE_DELAY 8
21+
#define DYNAMIC_KEYMAP_MACRO_DELAY 8
22+
#define EECONFIG_USER_DATA_SIZE 8
23+
24+
#define DEV_MODE_PIN C0
25+
#define SYS_MODE_PIN C1
26+
#define DC_BOOST_PIN C2
27+
#define NRF_RESET_PIN B4
28+
#define NRF_BOOT_PIN B5
29+
#define NRF_WAKEUP_PIN C4
30+
#define RGB_DRIVER_SDB1 C6
31+
#define RGB_DRIVER_SDB2 C7
32+
33+
#define SERIAL_DRIVER SD1
34+
#define SD1_TX_PIN B6
35+
#define SD1_TX_PAL_MODE 0
36+
#define SD1_RX_PIN B7
37+
#define SD1_RX_PAL_MODE 0
38+
39+
// This is a 7-bit address, that gets left-shifted and bit 0
40+
// set to 0 for write, 1 for read (as per I2C protocol)
41+
// The address will vary depending on your wiring:
42+
// 0b1110100 AD <-> GND
43+
// 0b1110111 AD <-> VCC
44+
// 0b1110101 AD <-> SCL
45+
// 0b1110110 AD <-> SDA
46+
#define DRIVER_ADDR_1 0b1010000
47+
#define DRIVER_ADDR_2 0b1010011
48+
49+
#define ISSI_TIMEOUT 1
50+
51+
#define I2C_DRIVER I2CD1
52+
#define I2C1_SCL_PIN B8
53+
#define I2C1_SDA_PIN B9
54+
#define I2C1_CLOCK_SPEED 1000000
55+
56+
#define I2C1_SCL_PAL_MODE 1
57+
#define I2C1_SDA_PAL_MODE 1
58+
59+
#define I2C1_TIMINGR_PRESC 0U
60+
#define I2C1_TIMINGR_SCLDEL 0U
61+
#define I2C1_TIMINGR_SDADEL 0U
62+
#define I2C1_TIMINGR_SCLH 0U
63+
#define I2C1_TIMINGR_SCLL 0U
64+
#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_16_9
65+
66+
#define DRIVER_COUNT 2
67+
#define DRIVER_1_LED_TOTAL 58
68+
#define DRIVER_2_LED_TOTAL (42 + 10)
69+
#define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
70+
71+
#define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT
72+
73+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Copyright 2023 @ Nuphy <https://nuphy.com/>
3+
4+
This program is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 2 of the License, or
7+
(at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#pragma once
19+
20+
#include_next <halconf.h>
21+
22+
#undef HAL_USE_SERIAL
23+
#define HAL_USE_SERIAL TRUE
24+
25+
#undef HAL_USE_I2C
26+
#define HAL_USE_I2C TRUE
27+

0 commit comments

Comments
 (0)