diff options
author | patrickmt <40182064+patrickmt@users.noreply.github.com> | 2018-12-18 15:21:25 -0500 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2019-01-07 12:44:55 -0800 |
commit | 6e984a8b5e34ba181b0893a929af569a1faef2b6 (patch) | |
tree | 3648fd159ef02fe3ed7d8ae80c2755c580cd59ff /keyboards/massdrop | |
parent | 28986998046b4dbdbc228dbb7889836de2a3ee18 (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')
-rw-r--r-- | keyboards/massdrop/alt/matrix.c | 12 | ||||
-rw-r--r-- | keyboards/massdrop/ctrl/matrix.c | 12 |
2 files changed, 6 insertions, 18 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; diff --git a/keyboards/massdrop/ctrl/matrix.c b/keyboards/massdrop/ctrl/matrix.c index 3580577dc1..5f1741e58a 100644 --- a/keyboards/massdrop/ctrl/matrix.c +++ b/keyboards/massdrop/ctrl/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; |