archimedes: tune delay time
This commit is contained in:
parent
326cfc57bd
commit
28508afb7d
1 changed files with 34 additions and 15 deletions
|
|
@ -23,6 +23,7 @@ SOFTWARE.
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
#include "protocol/serial.h"
|
#include "protocol/serial.h"
|
||||||
|
#include "wait.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
|
|
||||||
|
|
@ -96,22 +97,34 @@ uint8_t matrix_scan(void)
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case INIT:
|
case INIT:
|
||||||
send_cmd(0xFF);
|
// ignore unprocessed replies
|
||||||
_delay_ms(10);
|
|
||||||
check_reply();
|
check_reply();
|
||||||
|
|
||||||
|
// reset sequence
|
||||||
|
send_cmd(HRST);
|
||||||
|
wait_ms(1);
|
||||||
|
if (HRST != check_reply()) {
|
||||||
|
wait_ms(1000);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
send_cmd(RAK1);
|
send_cmd(RAK1);
|
||||||
_delay_ms(10);
|
wait_ms(1);
|
||||||
check_reply();
|
if (RAK1 != check_reply()) {
|
||||||
|
wait_ms(1000);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
send_cmd(RAK2);
|
send_cmd(RAK2);
|
||||||
_delay_ms(10);
|
wait_ms(1);
|
||||||
check_reply();
|
if (RAK2 != check_reply()) {
|
||||||
|
wait_ms(1000);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
//send_cmd(SACK);
|
// ack to scan now
|
||||||
send_cmd(SMAK);
|
send_cmd(SMAK);
|
||||||
check_reply();
|
check_reply();
|
||||||
|
|
||||||
state = SCAN;
|
state = SCAN;
|
||||||
break;
|
break;
|
||||||
case SCAN: {
|
case SCAN: {
|
||||||
|
|
@ -120,13 +133,14 @@ uint8_t matrix_scan(void)
|
||||||
switch (d) {
|
switch (d) {
|
||||||
case -1:
|
case -1:
|
||||||
// no reply
|
// no reply
|
||||||
//xprintf(".");
|
|
||||||
break;
|
break;
|
||||||
case KDDA ... KDDA+15:
|
case KDDA ... KDDA+15:
|
||||||
case KUDA ... KUDA+15:
|
case KUDA ... KUDA+15:
|
||||||
// key row
|
// key row
|
||||||
key = (d & 0xF) << 4;
|
key = (d & 0xF) << 4;
|
||||||
_delay_ms(1);
|
wait_us(100);
|
||||||
|
|
||||||
|
// ack for key data first byte
|
||||||
send_cmd(BACK);
|
send_cmd(BACK);
|
||||||
state = WAIT_KEY_COL;
|
state = WAIT_KEY_COL;
|
||||||
break;
|
break;
|
||||||
|
|
@ -145,12 +159,17 @@ uint8_t matrix_scan(void)
|
||||||
break;
|
break;
|
||||||
case KDDA ... KDDA+15:
|
case KDDA ... KDDA+15:
|
||||||
case KUDA ... KUDA+15:
|
case KUDA ... KUDA+15:
|
||||||
if ((d & KUDA) == KUDA) { key |= 0x80; } // key up flag
|
// key col
|
||||||
key |= d & 0xF;
|
key |= d & 0xF;
|
||||||
xprintf("[k%02X] ", key);
|
if ((d & KUDA) == KUDA) { key |= 0x80; } // key up flag
|
||||||
_delay_ms(1);
|
//
|
||||||
|
// ack
|
||||||
|
wait_us(100);
|
||||||
send_cmd(SMAK);
|
send_cmd(SMAK);
|
||||||
state = SCAN;
|
state = SCAN;
|
||||||
|
|
||||||
|
// TODO: make/brak key
|
||||||
|
xprintf("[k%02X] ", key);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// error
|
// error
|
||||||
|
|
@ -164,10 +183,10 @@ uint8_t matrix_scan(void)
|
||||||
// TODO
|
// TODO
|
||||||
// toggle ScrollLock LED
|
// toggle ScrollLock LED
|
||||||
/*
|
/*
|
||||||
_delay_ms(10);
|
wait_ms(10);
|
||||||
arc_led = arc_led ^ 1<<ARC_LED_SCROLL_LOCK;
|
arc_led = arc_led ^ 1<<ARC_LED_SCROLL_LOCK;
|
||||||
serial_send(LEDS(arc_led % 8));
|
serial_send(LEDS(arc_led % 8));
|
||||||
_delay_ms(500);
|
wait_ms(500);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue