summaryrefslogtreecommitdiff
path: root/keyboards/phoenix/phoenix.c
diff options
context:
space:
mode:
authorLSChyi <alan81920@gmail.com>2020-09-14 18:33:43 +0800
committerGitHub <noreply@github.com>2020-09-14 03:33:43 -0700
commit02551ae4991d818adb824fe39a82437281ee5306 (patch)
tree334a8c57c8913d9b55a1bd10ce2f451ff150ad60 /keyboards/phoenix/phoenix.c
parent6499eb6a3c512ded96443649d66274ce1064df0f (diff)
[Keyboard] add Phoenix keyboard (#10256)
* setup keyboard * fit v1 board setting * remove unused def and add ergodox_pretty * add user hooks * add ergodox_pretty to info * apply suggestions * use default split usb timeout
Diffstat (limited to 'keyboards/phoenix/phoenix.c')
-rw-r--r--keyboards/phoenix/phoenix.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/keyboards/phoenix/phoenix.c b/keyboards/phoenix/phoenix.c
new file mode 100644
index 0000000000..e79b35b159
--- /dev/null
+++ b/keyboards/phoenix/phoenix.c
@@ -0,0 +1,85 @@
+#include "hal.h"
+#include "usb_main.h"
+#include "phoenix.h"
+
+void bootmagic_lite(void) {
+ matrix_scan();
+ wait_ms(5);
+ matrix_scan();
+
+ if ((matrix_get_row(0) & 1) || (matrix_get_row(6) & 1)) {
+ palSetPadMode(GPIOB, 8, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPadMode(GPIOB, 5, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPadMode(GPIOB, 6, PAL_MODE_OUTPUT_PUSHPULL);
+ led1_off();
+ led2_off();
+ led3_off();
+
+ led3_on();
+ wait_ms(50);
+ led2_on();
+ wait_ms(50);
+ led1_on();
+ wait_ms(50);
+
+ led3_off();
+ wait_ms(50);
+ led2_off();
+ wait_ms(50);
+ led1_off();
+ wait_ms(50);
+
+ bootloader_jump();
+ }
+}
+
+void keyboard_pre_init_kb(void) {
+ palSetPadMode(GPIOB, 8, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPadMode(GPIOB, 5, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPadMode(GPIOB, 6, PAL_MODE_OUTPUT_PUSHPULL);
+ led1_off();
+ led2_off();
+ led3_off();
+
+ keyboard_pre_init_user();
+}
+
+void keyboard_post_init_kb(void) {
+ led1_on();
+ wait_ms(50);
+ led2_on();
+ wait_ms(50);
+ led3_on();
+ wait_ms(50);
+
+ led1_off();
+ wait_ms(50);
+ led2_off();
+ wait_ms(50);
+ led3_off();
+ wait_ms(50);
+
+ keyboard_post_init_user();
+}
+
+void manipulate_led(uint32_t led, bool on) {
+ switch (led) {
+ case 1:
+ on ? led1_on() : led1_off();
+ case 2:
+ on ? led2_on() : led2_off();
+ case 3:
+ on ? led3_on() : led3_off();
+ }
+}
+
+
+layer_state_t layer_state_set_kb(uint32_t state) {
+ state = layer_state_set_user(state);
+
+ uint8_t layer = get_highest_layer(state);
+ manipulate_led(1, layer & 1);
+ manipulate_led(2, layer >> 1 & 1);
+ manipulate_led(3, layer >> 2 & 1);
+ return state;
+}