summaryrefslogtreecommitdiffstats
path: root/keyboards/massdrop/alt
diff options
context:
space:
mode:
authorpatrickmt <40182064+patrickmt@users.noreply.github.com>2018-12-18 15:21:25 -0500
committerDrashna Jaelre <drashna@live.com>2019-01-07 12:44:55 -0800
commit6e984a8b5e34ba181b0893a929af569a1faef2b6 (patch)
tree3648fd159ef02fe3ed7d8ae80c2755c580cd59ff /keyboards/massdrop/alt
parent28986998046b4dbdbc228dbb7889836de2a3ee18 (diff)
Update to arm_atsam wait and timer routines
Microsecond (us) delays are now handled by a busy wait loop according to MCU frequency. This replaces the system counter method which had an overhead of around 12us. TC5 device and supporting routines removed as it was the old us delay counter. wait_ms is now properly a macro to CLK_delay_ms. wait_us is now properly a macro to CLK_delay_us. Removed CLK_get_us as it has no use. All calls to CLK_get_ms() have been replaced by timer_read64() with corrected typing. All calls to CLK_delay_ms() have been replaced by wait_ms(). All calls to CLK_delay_us() have been replaced by wait_us() and timings verified or updated as needed after review on scope. Corrected typing of variables using 64bit ms timer readings if needed.
Diffstat (limited to 'keyboards/massdrop/alt')
-rw-r--r--keyboards/massdrop/alt/matrix.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/keyboards/massdrop/alt/matrix.c b/keyboards/massdrop/alt/matrix.c
index 892d38791c..472479d303 100644
--- a/keyboards/massdrop/alt/matrix.c
+++ b/keyboards/massdrop/alt/matrix.c
@@ -79,8 +79,6 @@ void matrix_init(void)
matrix_init_quantum();
}
-#define MATRIX_SCAN_DELAY 10 //Delay after setting a col to output (in us)
-
uint64_t mdebouncing = 0;
uint8_t matrix_scan(void)
{
@@ -89,9 +87,7 @@ uint8_t matrix_scan(void)
uint8_t col;
uint32_t scans[2]; //PA PB
- if (CLK_get_ms() < mdebouncing) return 1; //mdebouncing == 0 when no debouncing active
-
- //DBG_1_OFF; //Profiling scans
+ if (timer_read64() < mdebouncing) return 1; //mdebouncing == 0 when no debouncing active
memset(mlatest, 0, MATRIX_ROWS * sizeof(matrix_row_t)); //Zero the result buffer
@@ -99,7 +95,7 @@ uint8_t matrix_scan(void)
{
PORT->Group[col_ports[col]].OUTSET.reg = 1 << col_pins[col]; //Set col output
- CLK_delay_us(MATRIX_SCAN_DELAY); //Delay for output
+ wait_us(1); //Delay for output
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
@@ -132,11 +128,9 @@ uint8_t matrix_scan(void)
else
{
//Begin or extend debounce on change
- mdebouncing = CLK_get_ms() + DEBOUNCING_DELAY;
+ mdebouncing = timer_read64() + DEBOUNCING_DELAY;
}
- //DBG_1_ON; //Profiling scans
-
matrix_scan_quantum();
return 1;