Implement matrix_io_delay abstraction for Drop boards (#11472)
This commit is contained in:
parent
2574bc2791
commit
b609a07b45
2 changed files with 14 additions and 2 deletions
|
@ -22,6 +22,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "clks.h"
|
#include "clks.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef MATRIX_IO_DELAY
|
||||||
|
# define MATRIX_IO_DELAY 1
|
||||||
|
#endif
|
||||||
|
|
||||||
matrix_row_t mlatest[MATRIX_ROWS];
|
matrix_row_t mlatest[MATRIX_ROWS];
|
||||||
matrix_row_t mlast[MATRIX_ROWS];
|
matrix_row_t mlast[MATRIX_ROWS];
|
||||||
matrix_row_t mdebounced[MATRIX_ROWS];
|
matrix_row_t mdebounced[MATRIX_ROWS];
|
||||||
|
@ -32,6 +36,8 @@ uint8_t col_ports[] = { MATRIX_COL_PORTS };
|
||||||
uint8_t col_pins[] = { MATRIX_COL_PINS };
|
uint8_t col_pins[] = { MATRIX_COL_PINS };
|
||||||
uint32_t row_masks[2]; //NOTE: If more than PA PB used in the future, adjust code to accomodate
|
uint32_t row_masks[2]; //NOTE: If more than PA PB used in the future, adjust code to accomodate
|
||||||
|
|
||||||
|
__attribute__((weak)) void matrix_io_delay(void) { wait_us(MATRIX_IO_DELAY); }
|
||||||
|
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
void matrix_init_kb(void) {
|
void matrix_init_kb(void) {
|
||||||
matrix_init_user();
|
matrix_init_user();
|
||||||
|
@ -95,7 +101,7 @@ uint8_t matrix_scan(void)
|
||||||
{
|
{
|
||||||
PORT->Group[col_ports[col]].OUTSET.reg = 1 << col_pins[col]; //Set col output
|
PORT->Group[col_ports[col]].OUTSET.reg = 1 << col_pins[col]; //Set col output
|
||||||
|
|
||||||
wait_us(1); //Delay for output
|
matrix_io_delay(); //Delay for output
|
||||||
|
|
||||||
scans[PA] = PORT->Group[PA].IN.reg & row_masks[PA]; //Read PA row pins data
|
scans[PA] = PORT->Group[PA].IN.reg & row_masks[PA]; //Read PA row pins data
|
||||||
scans[PB] = PORT->Group[PB].IN.reg & row_masks[PB]; //Read PB row pins data
|
scans[PB] = PORT->Group[PB].IN.reg & row_masks[PB]; //Read PB row pins data
|
||||||
|
|
|
@ -22,6 +22,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "clks.h"
|
#include "clks.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef MATRIX_IO_DELAY
|
||||||
|
# define MATRIX_IO_DELAY 1
|
||||||
|
#endif
|
||||||
|
|
||||||
matrix_row_t mlatest[MATRIX_ROWS];
|
matrix_row_t mlatest[MATRIX_ROWS];
|
||||||
matrix_row_t mlast[MATRIX_ROWS];
|
matrix_row_t mlast[MATRIX_ROWS];
|
||||||
matrix_row_t mdebounced[MATRIX_ROWS];
|
matrix_row_t mdebounced[MATRIX_ROWS];
|
||||||
|
@ -32,6 +36,8 @@ uint8_t col_ports[] = { MATRIX_COL_PORTS };
|
||||||
uint8_t col_pins[] = { MATRIX_COL_PINS };
|
uint8_t col_pins[] = { MATRIX_COL_PINS };
|
||||||
uint32_t row_masks[2]; //NOTE: If more than PA PB used in the future, adjust code to accomodate
|
uint32_t row_masks[2]; //NOTE: If more than PA PB used in the future, adjust code to accomodate
|
||||||
|
|
||||||
|
__attribute__((weak)) void matrix_io_delay(void) { wait_us(MATRIX_IO_DELAY); }
|
||||||
|
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
void matrix_init_kb(void) {
|
void matrix_init_kb(void) {
|
||||||
matrix_init_user();
|
matrix_init_user();
|
||||||
|
@ -95,7 +101,7 @@ uint8_t matrix_scan(void)
|
||||||
{
|
{
|
||||||
PORT->Group[col_ports[col]].OUTSET.reg = 1 << col_pins[col]; //Set col output
|
PORT->Group[col_ports[col]].OUTSET.reg = 1 << col_pins[col]; //Set col output
|
||||||
|
|
||||||
wait_us(1); //Delay for output
|
matrix_io_delay(); //Delay for output
|
||||||
|
|
||||||
scans[PA] = PORT->Group[PA].IN.reg & row_masks[PA]; //Read PA row pins data
|
scans[PA] = PORT->Group[PA].IN.reg & row_masks[PA]; //Read PA row pins data
|
||||||
scans[PB] = PORT->Group[PB].IN.reg & row_masks[PB]; //Read PB row pins data
|
scans[PB] = PORT->Group[PB].IN.reg & row_masks[PB]; //Read PB row pins data
|
||||||
|
|
Loading…
Reference in a new issue