Example #1
0
void init_pins() {
    MCF_GPIO_PANPAR = MCF_GPIO_PANPAR_PANPAR0;
    MCF_GPIO_DDRQS = 0;
    MCF_GPIO_PQSPAR = MCF_GPIO_PQSPAR_PQSPAR6(0x1) |
                      MCF_GPIO_PQSPAR_PQSPAR5(0x1) |
                      MCF_GPIO_PQSPAR_PQSPAR4(0x1) |
                      MCF_GPIO_PQSPAR_PQSPAR3(0x1) |
                      MCF_GPIO_PQSPAR_PQSPAR2(0x1) |
                      MCF_GPIO_PQSPAR_PQSPAR1(0x1) |
                      MCF_GPIO_PQSPAR_PQSPAR0(0x1);
}
Example #2
0
/*****************************************************************************
 * @name     GPIO_Init
 *
 * @brief:   Initialization of the GPIO.
 *
 * @param  : None
 *
 * @return : None
 *****************************************************************************
 *
 *
 ****************************************************************************/
void GPIO_Init(void)
{
 	/***************************************************************************
 	*						 GPIO Init for LED
 	*
 	****************************************************************************/		
	/* Configure LED io pins to be outputs.
	 * M52221DEMO: LED to port mapping
	 * LED1 LED2 LED3 LED4
	 *  |    |    |    |
	 *  ^    ^    ^    ^
	 * PTC0 PTC1 PTC2 PTC3 
	 */
	MCF_GPIO_DDRTC = (MCF_GPIO_DDRTC_DDRTC0 | 
					  MCF_GPIO_DDRTC_DDRTC1 | 
					  MCF_GPIO_DDRTC_DDRTC2 | 
					  MCF_GPIO_DDRTC_DDRTC3);
	/* Assign PORTC[0-3] as GPIO */
	MCF_GPIO_PTCPAR = MCF_GPIO_PTCPAR_PTCPAR0(MCF_GPIO_PTCPAR_DTIN0_GPIO) |
	                  MCF_GPIO_PTCPAR_PTCPAR1(MCF_GPIO_PTCPAR_DTIN1_GPIO) |
	                  MCF_GPIO_PTCPAR_PTCPAR2(MCF_GPIO_PTCPAR_DTIN2_GPIO) | 
	                  MCF_GPIO_PTCPAR_PTCPAR3(MCF_GPIO_PTCPAR_DTIN3_GPIO);
    
 	/***************************************************************************
 	*						 GPIO Init for USB
 	*
 	****************************************************************************/		    
    /* setup gpio state, func and dirrections */
    MCF_GPIO_PUAPAR &= 0x3f;
    MCF_GPIO_PORTUA |= MCF_GPIO_PORTUA_PORTUA3;   /* turn Vbus off */
	MCF_GPIO_DDRUA 	|= MCF_GPIO_DDRUA_DDRUA3;      /* CTS0 as output */
	
	MCF_GPIO_PUAPAR &= 0xcf;
	MCF_GPIO_DDRUA 	&= ~MCF_GPIO_DDRUA_DDRUA2;     /* RTS0 as input */
	
	MCF_GPIO_PORTUA &= ~MCF_GPIO_PORTUA_PORTUA3;  /* turn Vbus on  */
	
    MCF_GPIO_PQSPAR |= MCF_GPIO_PQSPAR_PQSPAR5(3) | MCF_GPIO_PQSPAR_PQSPAR6(3);	                  
    
 	/***************************************************************************
 	*						 GPIO Init for KBI
 	*
 	****************************************************************************/    
    /* Configure switch buttons */
	/* M52221DEMO: SW1 & SW2 connected to PNQ[1] & PNQ[7] */

	/* Pin assignement registers: IRQ */   	
	/* Assure that PDDPAR[5-7] are configured to GPIO regardless of the reset state */
	MCF_GPIO_PNQPAR &= ~(MCF_GPIO_PNQPAR_PNQPAR1(3) | MCF_GPIO_PNQPAR_PNQPAR7(3));
	MCF_GPIO_PNQPAR |= (MCF_GPIO_PNQPAR_IRQ1_IRQ1 | MCF_GPIO_PNQPAR_IRQ7_IRQ7); 
	
	/* Configure IRQ[1] & IRQ[7] as input */
	MCF_EPORT_EPDDR &= ~(MCF_EPORT_EPDDR_EPDD1 | MCF_EPORT_EPDDR_EPDD7); 
	/* Configure IRQ1 & IRQ7 as falling-edge sense */
	MCF_EPORT_EPPAR = MCF_EPORT_EPPAR_EPPA1_FALLING | MCF_EPORT_EPPAR_EPPA7_FALLING;
	/* Enable Interrupt for IRQ1 & IRQ7 */
	MCF_EPORT_EPIER = MCF_EPORT_EPIER_EPIE1 | MCF_EPORT_EPIER_EPIE7;  
	
	/***************************************************************************
 	*						 GPIO Init for QSPI
 	*
 	****************************************************************************/    
	/* Configure the pins for QSPI for specialized purpose */
	/* QSPI_CLK, QSPI_DOUT, QSPI_DIN, QSPI_CS0  */
	MCF_GPIO_PQSPAR &= ~(MCF_GPIO_PQSPAR_PQSPAR0(3) | 
	                	 MCF_GPIO_PQSPAR_PQSPAR1(3) | 
	                	 MCF_GPIO_PQSPAR_PQSPAR2(3) | 
	                	 MCF_GPIO_PQSPAR_PQSPAR3(3));  
	                	 
	MCF_GPIO_PQSPAR |= (MCF_GPIO_PQSPAR_QSPI_DOUT_DOUT |
				        MCF_GPIO_PQSPAR_QSPI_DIN_DIN   |
	  				    MCF_GPIO_PQSPAR_QSPI_CLK_CLK   |
	  				    MCF_GPIO_PQSPAR_QSPI_CS0_CS0);  	
}