mirror of
				https://github.com/brmlab/edubrm.git
				synced 2025-10-29 21:43:59 +01:00 
			
		
		
		
	testing IO pins
This commit is contained in:
		
							parent
							
								
									ba1bf945bd
								
							
						
					
					
						commit
						e38d475d40
					
				
					 4 changed files with 37 additions and 0 deletions
				
			
		
							
								
								
									
										4
									
								
								README
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								README
									
										
									
									
									
								
							|  | @ -20,3 +20,7 @@ Software | |||
| - required packages Ubuntu: | ||||
|   * pyqt4-dev-tools | ||||
|   * python-usb (from ppa:gekkio/pyusb) | ||||
| 
 | ||||
| TODO: | ||||
| 	prechod z MAX na 0 u PWM nefunguje | ||||
| 
 | ||||
|  |  | |||
|  | @ -64,6 +64,7 @@ void SetOutReport (uint8_t dst[], uint32_t length) | |||
| 			break; | ||||
| 		case 'P': | ||||
| 			states = dst[1]; | ||||
| 			PinDir(states); | ||||
| 			// TODO: set pins to states (1 is INPUT, 0 is OUTPUT)
 | ||||
| 			// pin1 is PIN_1
 | ||||
| 			// pin2 is PIN_2
 | ||||
|  | @ -72,6 +73,7 @@ void SetOutReport (uint8_t dst[], uint32_t length) | |||
| 		case 'o': | ||||
| 			which = dst[1] >> 1; | ||||
| 			state = dst[1] & 0x01; | ||||
| 			PinState(which, state); | ||||
| 			// TODO: set output pins (which) to state (state)
 | ||||
| 			// pin1 is PIN_1
 | ||||
| 			// pin2 is PIN_2
 | ||||
|  | @ -80,6 +82,24 @@ void SetOutReport (uint8_t dst[], uint32_t length) | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| void PinDir(uint16_t mask) { | ||||
| 	mask &= 7; | ||||
| 	mask = ((mask & 4) << 5) | ((mask & 2) << 5) | (mask & 1); | ||||
| 	LPC_GPIO2->DIR |= mask; | ||||
| 	mask |= ~(1<<0 | 1<<6 | 1<<7); | ||||
| 	LPC_GPIO2->DIR &= mask; | ||||
| 
 | ||||
| 	LPC_GPIO2->MASKED_ACCESS[1<<0] |= 1<<0; | ||||
| 	  LPC_GPIO2->MASKED_ACCESS[1<<6] |= 1<<6; | ||||
| 	  LPC_GPIO2->MASKED_ACCESS[1<<7] |= 1<<7; | ||||
| } | ||||
| 
 | ||||
| void PinState(uint8_t which, uint8_t state) { | ||||
| //	if (which > 1) which += 4;
 | ||||
| //	LPC_GPIO2->MASKED_ACCESS[1<<which] |= (1<<which);
 | ||||
| //	LPC_GPIO2->MASKED_ACCESS[1<<which] &= (1<<which);
 | ||||
| } | ||||
| 
 | ||||
| void TIMER16_1_IRQHandler(void) { | ||||
| 	LPC_TMR16B1->IR = 0xff; | ||||
| 	LPC_GPIO1->DIR ^= 1<<6; | ||||
|  |  | |||
|  | @ -2,3 +2,4 @@ void GetInReport (uint8_t src[], uint32_t length); | |||
| void SetOutReport (uint8_t dst[], uint32_t length); | ||||
| void EnablePWM1(uint32_t period, uint32_t duty); | ||||
| void EnablePWM2(uint16_t period, uint16_t duty); | ||||
| void PinDir(uint16_t mask); | ||||
|  |  | |||
|  | @ -77,6 +77,18 @@ int main (void) | |||
| 
 | ||||
|   for (n = 0; n < 75; n++) {} | ||||
| 
 | ||||
|   LPC_GPIO2->DIR &= ~(1<<0); // pin2
 | ||||
|   LPC_GPIO2->DIR &= ~(1<<6); // pin1
 | ||||
|   LPC_GPIO2->DIR &= ~(1<<7); // pin3
 | ||||
| 
 | ||||
|   LPC_GPIO2->DIR |= (1<<0); | ||||
|   LPC_GPIO2->DIR |= (1<<6); | ||||
|   LPC_GPIO2->DIR |= (1<<7); | ||||
| 
 | ||||
|   LPC_GPIO2->MASKED_ACCESS[1<<0] |= 1<<0; | ||||
|   LPC_GPIO2->MASKED_ACCESS[1<<6] |= 1<<6; | ||||
|   LPC_GPIO2->MASKED_ACCESS[1<<7] |= 1<<7; | ||||
| 
 | ||||
|   while (1) | ||||
| 	  __WFI(); | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 BIITER
						BIITER