Add readPort() and some API to 'tmk_core/common/*/gpio.h' (#12754)
* add readPort() and some API to 'tmk_core/common/*/gpio.h' The following macros have been added to gpio.h. * readPort(port) * setPortBitInput(port, bit) * setPortBitInputHigh(port, bit) * setPortBitOutput(port, bit) * writePortBitLow(port, bit) * writePortBitHigh(port, bit) * add data type 'port_data_t' into gpio.h * rename qmk_pin to pin
This commit is contained in:
		
							parent
							
								
									59862d30d0
								
							
						
					
					
						commit
						b72f10c635
					
				
					 2 changed files with 31 additions and 0 deletions
				
			
		|  | @ -20,6 +20,8 @@ | |||
| 
 | ||||
| typedef uint8_t pin_t; | ||||
| 
 | ||||
| /* Operation of GPIO by pin. */ | ||||
| 
 | ||||
| #define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF)) | ||||
| #define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF)) | ||||
| #define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low") | ||||
|  | @ -32,3 +34,16 @@ typedef uint8_t pin_t; | |||
| #define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF))) | ||||
| 
 | ||||
| #define togglePin(pin) (PORTx_ADDRESS(pin) ^= _BV((pin)&0xF)) | ||||
| 
 | ||||
| /* Operation of GPIO by port. */ | ||||
| 
 | ||||
| typedef uint8_t port_data_t; | ||||
| 
 | ||||
| #define readPort(port) PINx_ADDRESS(port) | ||||
| 
 | ||||
| #define setPortBitInput(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) &= ~_BV((bit)&0xF)) | ||||
| #define setPortBitInputHigh(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) |= _BV((bit)&0xF)) | ||||
| #define setPortBitOutput(port, bit) (DDRx_ADDRESS(port) |= _BV((bit)&0xF)) | ||||
| 
 | ||||
| #define writePortBitLow(port, bit) (PORTx_ADDRESS(port) &= ~_BV((bit)&0xF)) | ||||
| #define writePortBitHigh(port, bit) (PORTx_ADDRESS(port) |= _BV((bit)&0xF)) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Takeshi ISHII
						Takeshi ISHII