Move F_CPU to header file and clean up 2560 read_row() code

This commit is contained in:
Dave 2020-05-12 17:09:49 -05:00
parent 9b41a77ea4
commit 3c1d050abb
4 changed files with 17 additions and 8 deletions

View File

@ -33,6 +33,7 @@
// 23-25 PORTC0-2 ROW outputs (row number)
// 27 PORTC4
#include "asdf_arch.h"
#include <avr/io.h>
#include <avr/interrupt.h>
@ -40,7 +41,6 @@
#include <stdint.h>
#include "asdf_config.h"
#include "asdf_arch.h"
#include "asdf_keymap_defs.h"
// Tick is true every 1 ms.
@ -728,6 +728,10 @@ void asdf_arch_init(void)
// "1". So, if a keypress pulls the column line low, then the reading of the
// physical bits must be inverted.
//
// 2) A small delay (2usec) is required between setting the keyboard row outputs
// and reading the columns, which I think is due to capacitance across the
// reverse-biased diodes.
//
// SCOPE: public
//
// COMPLEXITY: 1
@ -735,13 +739,13 @@ void asdf_arch_init(void)
asdf_cols_t asdf_arch_read_row(uint8_t row)
{
uint32_t rows = ~(1L << row);
asdf_cols_t cols;
ASDF_LOROW_PORT = (uint8_t)(rows & 0xff);
ASDF_HIROW_PORT = (uint8_t)((rows >> 8) & 0xff);
cols = ~(asdf_cols_t) ASDF_COLUMNS_PIN;
ASDF_HIROW_PORT = 0xff;
ASDF_LOROW_PORT = 0xff;
return cols;
_delay_us(ASDF_KEYBOARD_ROW_SETTLING_TIME_US);
return ~(asdf_cols_t) ASDF_COLUMNS_PIN;
}
// PROCEDURE: asdf_arch_osi_read_row

View File

@ -33,8 +33,11 @@
// ASDF keyboard definitions:
#define ASDF_STROBE_LENGTH_US 10 // strobe length in microseconds
#define F_CPU 16000000L
#define ASDF_STROBE_LENGTH_US 10 // strobe length in microseconds
#define ASDF_KEYBOARD_ROW_SETTLING_TIME_US 2 // time for keyboard capacitance to
// settle before sampling
// Clock definitions:
#define SYSCLK_DIV1 0

View File

@ -33,13 +33,13 @@
// 23-25 PORTC0-2 ROW outputs (row number)
// 27 PORTC4
#include "asdf_arch.h"
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdint.h>
#include "asdf_config.h"
#include "asdf_arch.h"
#include "asdf_keymap_defs.h"
static volatile uint8_t tick = 0;

View File

@ -33,6 +33,8 @@
// ASDF keyboard definitions:
#define F_CPU 8000000L
#define ASDF_STROBE_LENGTH_US 10 // strobe length in microseconds