Move more UART-based keyboards to use timeout correctly. (#17329)
Co-authored-by: Tomasz Janeczko <tomasz.j@hey.com>
This commit is contained in:
		
							parent
							
								
									f6a7bf2a83
								
							
						
					
					
						commit
						6567b21688
					
				
					 13 changed files with 111 additions and 31 deletions
				
			
		| 
						 | 
				
			
			@ -20,6 +20,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		|||
#include "matrix.h"
 | 
			
		||||
#include "uart.h"
 | 
			
		||||
 | 
			
		||||
#define UART_MATRIX_RESPONSE_TIMEOUT 10000
 | 
			
		||||
 | 
			
		||||
void matrix_init_custom(void) {
 | 
			
		||||
    uart_init(1000000);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -41,11 +43,16 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) {
 | 
			
		|||
        //harm to leave it in here
 | 
			
		||||
        while (!uart_available()) {
 | 
			
		||||
            timeout++;
 | 
			
		||||
            if (timeout > 10000) {
 | 
			
		||||
            if (timeout > UART_MATRIX_RESPONSE_TIMEOUT) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        uart_data[i] = uart_read();
 | 
			
		||||
 | 
			
		||||
        if (timeout < UART_MATRIX_RESPONSE_TIMEOUT) {
 | 
			
		||||
            uart_data[i] = uart_read();
 | 
			
		||||
        } else {
 | 
			
		||||
            uart_data[i] = 0x00;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //check for the end packet, the key state bytes use the LSBs, so 0xE0
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue