Relocate PS2 code (#14895)
* Relocate ps2 protocol code * clang * Move makefile logic
This commit is contained in:
		
							parent
							
								
									5500c428dd
								
							
						
					
					
						commit
						d4be4b67a2
					
				
					 11 changed files with 38 additions and 32 deletions
				
			
		
							
								
								
									
										51
									
								
								platforms/avr/drivers/ps2/ps2_io.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								platforms/avr/drivers/ps2/ps2_io.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,51 @@ | |||
| #include <stdbool.h> | ||||
| #include "ps2_io.h" | ||||
| #include "gpio.h" | ||||
| #include "wait.h" | ||||
| 
 | ||||
| /* Check port settings for clock and data line */ | ||||
| #if !(defined(PS2_CLOCK_PIN)) | ||||
| #    error "PS/2 clock setting is required in config.h" | ||||
| #endif | ||||
| 
 | ||||
| #if !(defined(PS2_DATA_PIN)) | ||||
| #    error "PS/2 data setting is required in config.h" | ||||
| #endif | ||||
| 
 | ||||
| /*
 | ||||
|  * Clock | ||||
|  */ | ||||
| void clock_init(void) {} | ||||
| 
 | ||||
| void clock_lo(void) { | ||||
|     // Transition from input with pull-up to output low via Hi-Z instead of output high
 | ||||
|     writePinLow(PS2_CLOCK_PIN); | ||||
|     setPinOutput(PS2_CLOCK_PIN); | ||||
| } | ||||
| 
 | ||||
| void clock_hi(void) { setPinInputHigh(PS2_CLOCK_PIN); } | ||||
| 
 | ||||
| bool clock_in(void) { | ||||
|     setPinInputHigh(PS2_CLOCK_PIN); | ||||
|     wait_us(1); | ||||
|     return readPin(PS2_CLOCK_PIN); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * Data | ||||
|  */ | ||||
| void data_init(void) {} | ||||
| 
 | ||||
| void data_lo(void) { | ||||
|     // Transition from input with pull-up to output low via Hi-Z instead of output high
 | ||||
|     writePinLow(PS2_DATA_PIN); | ||||
|     setPinOutput(PS2_DATA_PIN); | ||||
| } | ||||
| 
 | ||||
| void data_hi(void) { setPinInputHigh(PS2_DATA_PIN); } | ||||
| 
 | ||||
| bool data_in(void) { | ||||
|     setPinInputHigh(PS2_DATA_PIN); | ||||
|     wait_us(1); | ||||
|     return readPin(PS2_DATA_PIN); | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Joel Challis
						Joel Challis