Add named macros to the board joystick drivers where a shift is needed to maintain unique joystick direction bits in the returned mask value.
This commit is contained in:
		
							parent
							
								
									b35f93a372
								
							
						
					
					
						commit
						95a1aa4c01
					
				
					 3 changed files with 14 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -66,6 +66,8 @@
 | 
			
		|||
		/* Macros: */
 | 
			
		||||
			#define JOY_BMASK                 ((1 << 5) | (1 << 6) | (1 << 7))
 | 
			
		||||
			#define JOY_EMASK                 ((1 << 4) | (1 << 5))
 | 
			
		||||
			
 | 
			
		||||
			#define JOY_PORTE_MASK_SHIFT      1
 | 
			
		||||
	#endif
 | 
			
		||||
 | 
			
		||||
	/* Public Interface - May be used in end-application: */
 | 
			
		||||
| 
						 | 
				
			
			@ -74,13 +76,13 @@
 | 
			
		|||
			#define JOY_LEFT                  (1 << 6)
 | 
			
		||||
 | 
			
		||||
			/** Mask for the joystick being pushed in the right direction. */
 | 
			
		||||
			#define JOY_RIGHT                ((1 << 4) >> 1)
 | 
			
		||||
			#define JOY_RIGHT                ((1 << 4) >> JOY_PORTE_MASK_SHIFT)
 | 
			
		||||
 | 
			
		||||
			/** Mask for the joystick being pushed in the upward direction. */
 | 
			
		||||
			#define JOY_UP                    (1 << 7)
 | 
			
		||||
 | 
			
		||||
			/** Mask for the joystick being pushed in the downward direction. */
 | 
			
		||||
			#define JOY_DOWN                 ((1 << 5) >> 1)
 | 
			
		||||
			#define JOY_DOWN                 ((1 << 5) >> JOY_PORTE_MASK_SHIFT)
 | 
			
		||||
 | 
			
		||||
			/** Mask for the joystick being pushed inward. */
 | 
			
		||||
			#define JOY_PRESS                 (1 << 5)
 | 
			
		||||
| 
						 | 
				
			
			@ -99,7 +101,7 @@
 | 
			
		|||
			static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
 | 
			
		||||
			static inline uint8_t Joystick_GetStatus(void)
 | 
			
		||||
			{
 | 
			
		||||
				return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> 1));
 | 
			
		||||
				return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> JOY_PORTE_MASK_SHIFT));
 | 
			
		||||
			}
 | 
			
		||||
		#endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue