From e259a722e7e8abcb97606b6cfbcce99667a66277 Mon Sep 17 00:00:00 2001 From: Jun Wako Date: Fri, 2 Jan 2015 21:16:40 +0900 Subject: Add keyboard/infinity --- keyboard/infinity/main.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 keyboard/infinity/main.cpp (limited to 'keyboard/infinity/main.cpp') diff --git a/keyboard/infinity/main.cpp b/keyboard/infinity/main.cpp new file mode 100644 index 0000000000..7db59cdfb9 --- /dev/null +++ b/keyboard/infinity/main.cpp @@ -0,0 +1,29 @@ +//#include "mbed.h" +#include "MK20D5.h" +#include "wait.h" +#include "gpio_api.h" +#include "PinNames.h" + + +//DigitalOut led(PTA19); + +int main() { + gpio_t led; + gpio_init_out(&led, PTA19); + while(1) { + gpio_write(&led, 1); + wait_ms(500); + gpio_write(&led, 0); + wait_ms(500); + } +/* + SIM->SCGC6 |= SIM_SCGC5_PORTA_MASK; + PORTA->PCR[19] = PORT_PCR_SRE_MASK | PORT_PCR_DSE_MASK | PORT_PCR_MUX(1); + PTA->PDDR |= (1<<19); + PTA->PSOR |= (1<<19); + while(1) { + PTA->PTOR |= (1<<19); + wait_ms(500); + } +*/ +} -- cgit v1.2.3 From 4acde45102cbf7b29f524c227bcd1c11aa83ebc0 Mon Sep 17 00:00:00 2001 From: Jun Wako Date: Sat, 3 Jan 2015 20:21:23 +0900 Subject: Fix linker script for NVIC vector on RAM --- keyboard/infinity/main.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'keyboard/infinity/main.cpp') diff --git a/keyboard/infinity/main.cpp b/keyboard/infinity/main.cpp index 7db59cdfb9..f28840d3ef 100644 --- a/keyboard/infinity/main.cpp +++ b/keyboard/infinity/main.cpp @@ -5,25 +5,16 @@ #include "PinNames.h" -//DigitalOut led(PTA19); - int main() { gpio_t led; gpio_init_out(&led, PTA19); while(1) { - gpio_write(&led, 1); - wait_ms(500); - gpio_write(&led, 0); - wait_ms(500); - } -/* - SIM->SCGC6 |= SIM_SCGC5_PORTA_MASK; - PORTA->PCR[19] = PORT_PCR_SRE_MASK | PORT_PCR_DSE_MASK | PORT_PCR_MUX(1); - PTA->PDDR |= (1<<19); - PTA->PSOR |= (1<<19); - while(1) { - PTA->PTOR |= (1<<19); wait_ms(500); + uint32_t delay = 0xf; + while (delay--) { + uint32_t delay2 = 0xffff; + while (delay2--) ; + } + gpio_write(&led, !gpio_read(&led)); } -*/ } -- cgit v1.2.3 From d0fefb76f8a1430c749e67bc72b4dba00c7143c9 Mon Sep 17 00:00:00 2001 From: Jun Wako Date: Sun, 4 Jan 2015 17:03:47 +0900 Subject: infinity: Add initial files for keyboard support --- keyboard/infinity/main.cpp | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'keyboard/infinity/main.cpp') diff --git a/keyboard/infinity/main.cpp b/keyboard/infinity/main.cpp index f28840d3ef..847668a1de 100644 --- a/keyboard/infinity/main.cpp +++ b/keyboard/infinity/main.cpp @@ -1,20 +1,44 @@ -//#include "mbed.h" #include "MK20D5.h" #include "wait.h" #include "gpio_api.h" #include "PinNames.h" +#include "matrix.h" +#include "timer.h" + +#include "action.h" +#include "keycode.h" +#include "host.h" +#include "host_driver.h" +#include "mbed_driver.h" int main() { gpio_t led; gpio_init_out(&led, PTA19); + + uint16_t t = 0; + + host_set_driver(&mbed_driver); + keyboard_init(); + while(1) { - wait_ms(500); - uint32_t delay = 0xf; - while (delay--) { - uint32_t delay2 = 0xffff; - while (delay2--) ; + keyboard_task(); + + bool matrix_on = false; + matrix_scan(); + for (int i = 0; i < MATRIX_ROWS; i++) { + if (matrix_get_row(i)) { + matrix_on = true; + break; + } + } + if (matrix_on) + gpio_write(&led, 1); + else { + if (timer_elapsed(t) > 500) { + gpio_write(&led, !gpio_read(&led)); + t = timer_read(); + } } - gpio_write(&led, !gpio_read(&led)); } } -- cgit v1.2.3