コード例 #1
0
ファイル: ciaaIO.c プロジェクト: cpantel/ciaa
void ciaaIOInit(void)
{
	Chip_GPIO_Init(LPC_GPIO_PORT);

   /* LEDs */
   Chip_SCU_PinMux(2,0,MD_PUP,FUNC4);  /* GPIO5[0], LED0R */
   Chip_SCU_PinMux(2,1,MD_PUP,FUNC4);  /* GPIO5[1], LED0G */
   Chip_SCU_PinMux(2,2,MD_PUP,FUNC4);  /* GPIO5[2], LED0B */
   Chip_SCU_PinMux(2,10,MD_PUP,FUNC0); /* GPIO0[14], LED1 */
   Chip_SCU_PinMux(2,11,MD_PUP,FUNC0); /* GPIO1[11], LED2 */
   Chip_SCU_PinMux(2,12,MD_PUP,FUNC0); /* GPIO1[12], LED3 */

   Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2),1);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<14),1);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<11)|(1<<12),1);

   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 0,(1<<14));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<11)|(1<<12));

   /* Switches */
   Chip_SCU_PinMux(1,0,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[4], SW1 */
   Chip_SCU_PinMux(1,1,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[8], SW2 */
   Chip_SCU_PinMux(1,2,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[9], SW3 */
   Chip_SCU_PinMux(1,6,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO1[9], SW4 */

   Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<4)|(1<<8)|(1<<9),0);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<9),0);
}
コード例 #2
0
ファイル: Outputs.c プロジェクト: ernesto-g/prog_up_entregas
void Board_Outputs_Init(void)
{

   /* Config EDU-CIAA-NXP Led Pins as GPIOs */
   Chip_SCU_PinMux(gpioLed1.portNumber,gpioLed1.portPin,MD_PUP,gpioLed1.func);
   Chip_SCU_PinMux(gpioLed2.portNumber,gpioLed2.portPin,MD_PUP,gpioLed2.func);
   Chip_SCU_PinMux(gpioLed3.portNumber,gpioLed3.portPin,MD_PUP,gpioLed3.func);

   Chip_SCU_PinMux(2,0,MD_PUP,FUNC4);  /* GPIO5[0],  LEDR */
   Chip_SCU_PinMux(2,1,MD_PUP,FUNC4);  /* GPIO5[1],  LEDG */
   Chip_SCU_PinMux(2,2,MD_PUP,FUNC4);  /* GPIO5[2],  LEDB */
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2),1);
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2));


   /* Config EDU-CIAA-NXP Led Pins as Outputs */
   Chip_GPIO_SetDir(LPC_GPIO_PORT, gpioLed1.gpioNumber,(1<<gpioLed1.gpioPin),1);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, gpioLed2.gpioNumber,(1<<gpioLed2.gpioPin),1);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, gpioLed3.gpioNumber,(1<<gpioLed3.gpioPin),1);

   /* Init EDU-CIAA-NXP Led Pins OFF */
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, gpioLed1.gpioNumber,(1<<gpioLed1.gpioPin));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, gpioLed2.gpioNumber,(1<<gpioLed2.gpioPin));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, gpioLed3.gpioNumber,(1<<gpioLed3.gpioPin));

}
コード例 #3
0
int main(void)
{
   /* perform the needed initialization here */


	volatile uint64_t i;


    Chip_GPIO_Init(LPC_GPIO_PORT);
    Chip_SCU_PinMux(2,0,MD_PUP,FUNC4);  /* remapea P2_0  en GPIO5[0], LED0R y habilita el pull up*/
    Chip_SCU_PinMux(2,1,MD_PUP,FUNC4);  /* remapea P2_1  en GPIO5[1], LED0G y habilita el pull up */
    Chip_SCU_PinMux(2,2,MD_PUP,FUNC4);  /* remapea P2_2  en GPIO5[2], LED0B y habilita el pull up */
    Chip_SCU_PinMux(2,10,MD_PUP,FUNC0); /* remapea P2_10 en GPIO0[14], LED1 y habilita el pull up */
    Chip_SCU_PinMux(2,11,MD_PUP,FUNC0); /* remapea P2_11 en GPIO1[11], LED2 y habilita el pull up */
    Chip_SCU_PinMux(2,12,MD_PUP,FUNC0); /* remapea P2_12 en GPIO1[12], LED3 y habilita el pull up */

    Chip_SCU_PinMux(1,0,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* remapea P1_0  en GPIO 0[4], SW1 */
    Chip_SCU_PinMux(1,1,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* remapea P1_1  en GPIO 0[8], SW2 */
    Chip_SCU_PinMux(1,2,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* remapea P1_2  en GPIO 0[9], SW3 */
    Chip_SCU_PinMux(1,6,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* remapea P1_6  en GPIO 1[9], SW4 */


    Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2),1);
    Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<14),1);
    Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<11)|(1<<12),1);

    Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2));
    Chip_GPIO_ClearValue(LPC_GPIO_PORT, 0,(1<<14));
    Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<11)|(1<<12));



       while(1) {
            /* add your code here */
    	     Chip_GPIO_SetPortToggle(LPC_GPIO_PORT,0,1<<14);      //Puerto 5  bit 0 --> LED ROJO
             //Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5, 1);





             //Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT,5,0);      //Puerto 5  bit 0 --> LED ROJO
             for (i=0;i<3000000;i++){
               asm  ("nop");
               }
            // Chip_GPIO_SetPinOutHigh(LPC_GPIO_PORT, 5, 0);   //Puerto 5  bit 0 --> LED ROJO
             //for (i=0;i<3000000;i++){
             //  asm  ("nop");
             //  }
         }
         return 0;


}
コード例 #4
0
ファイル: led.c プロジェクト: xsantinos/EDU-CIAA
/*Configuración de los pines/puertos*/
void InitGPIO_EDUCIAA_Leds(void)
{
	Chip_GPIO_Init(LPC_GPIO_PORT);
/*Mapeo de pines de los leds RGB:
 * El primer número corresponde al número de paquete de pines del micro.
 * El segundo número corresponde al pin dentro de ese paquete.
 * MD_PUP habilita el pull up de ese pin. Por lo tanto, se habilita para los tres.
 * FUNC4 establece la función del pin, que corresponde a GPIO para los tres.
 * De este modo, el mapeo resulta:
 * 		P2_0 (LED0R) en GPIO 5[0]
 * 		P2_1 (LED0G) en GPIO 5[1]
 * 		P2_2 (LED0B) en GPIO 5[2]*/
	Chip_SCU_PinMux( LED_RGB_R_PACK_NUMBER, LED_RGB_R_GPIO_PIN, MD_PUP, FUNC4);
    Chip_SCU_PinMux( LED_RGB_G_PACK_NUMBER, LED_RGB_G_GPIO_PIN, MD_PUP, FUNC4);
    Chip_SCU_PinMux( LED_RGB_B_PACK_NUMBER, LED_RGB_B_GPIO_PIN, MD_PUP, FUNC4);

/*Mapeo de pines de los leds 1, 2 y 3:
 * El primer número corresponde al número de paquete de pines del micro.
 * El segundo número corresponde al pin dentro de ese paquete.
 * MD_PUP habilita el pull up de ese pin. Por lo tanto, se habilita para los tres.
 * FUNC4 establece la función del pin, que corresponde a GPIO para los tres.
 * De este modo, el mapeo resulta:
 * 		P2_10 (LED1) en GPIO 0[14]
 * 		P2_11 (LED2) en GPIO 1[11]
 * 		P2_12 (LED3) en GPIO 1[12]*/
    Chip_SCU_PinMux( LED_1_PACK_NUMBER,LED_1_PACK_PIN, MD_PUP, FUNC0);
    Chip_SCU_PinMux( LED_2_PACK_NUMBER,LED_2_PACK_PIN, MD_PUP, FUNC0);
    Chip_SCU_PinMux( LED_3_PACK_NUMBER,LED_3_PACK_PIN, MD_PUP, FUNC0);

/* Configuración como salida para los leds RGB */
    Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<0),1);
    Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<2),1);
    Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<1),1);



    /* Configuración como salida para el led LED1 */
    Chip_GPIO_SetDir(LPC_GPIO_PORT, LED_1_GPIO_NUMBER,(1<<14),1);
    /* Configuración como salida para los leds LED2 y LED3 */
    Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<11)|(1<<12),1);

    /*Se apagan los leds.*/
    Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2));
    Chip_GPIO_ClearValue(LPC_GPIO_PORT, 0,(1<<14));
    Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<11)|(1<<12));
}
コード例 #5
0
ファイル: board.c プロジェクト: ernesto-g/workspace
static void Board_LED_Init()
{
	/* LEDs EDU-CIAA-NXP */
	Chip_SCU_PinMux(2,0,MD_PUP|MD_EZI,FUNC4);  /* GPIO5[0], LED0R */
	Chip_SCU_PinMux(2,1,MD_PUP|MD_EZI,FUNC4);  /* GPIO5[1], LED0G */
	Chip_SCU_PinMux(2,2,MD_PUP|MD_EZI,FUNC4);  /* GPIO5[2], LED0B */
	Chip_SCU_PinMux(2,10,MD_PUP|MD_EZI,FUNC0); /* GPIO0[14], LED1 */
	Chip_SCU_PinMux(2,11,MD_PUP|MD_EZI,FUNC0); /* GPIO1[11], LED2 */
	Chip_SCU_PinMux(2,12,MD_PUP|MD_EZI,FUNC0); /* GPIO1[12], LED3 */

	Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2),1);
	Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<14),1);
	Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<11)|(1<<12),1);

	Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2));
	Chip_GPIO_ClearValue(LPC_GPIO_PORT, 0,(1<<14));
	Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<11)|(1<<12));
}
コード例 #6
0
ファイル: bm_blinking.c プロジェクト: jmreta/edu_ciaa_C
/** \brief Main function
 *
 * This is the main entry point of the software.
 *
 * \returns 0
 *
 * \remarks This function never returns. Return value is only to avoid compiler
 *          warnings or errors.
 */
int main(void)
{


	   Chip_SCU_PinMux(1,0,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[4], SW1 */
	   Chip_SCU_PinMux(1,1,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[8], SW2 */
	   Chip_SCU_PinMux(1,2,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[9], SW3 */
	   Chip_SCU_PinMux(1,6,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO1[9], SW4 */

	   Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<4)|(1<<8)|(1<<9),0);
	   Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<9),0);

	   /* LEDs */
	   Chip_SCU_PinMux(2,0,MD_PUP,FUNC4);  /* GPIO5[0], LED0R */
	   Chip_SCU_PinMux(2,1,MD_PUP,FUNC4);  /* GPIO5[1], LED0G */
	   Chip_SCU_PinMux(2,2,MD_PUP,FUNC4);  /* GPIO5[2], LED0B */
	   Chip_SCU_PinMux(2,10,MD_PUP,FUNC0); /* GPIO0[14], LED1 */
	   Chip_SCU_PinMux(2,11,MD_PUP,FUNC0); /* GPIO1[11], LED2 */
	   Chip_SCU_PinMux(2,12,MD_PUP,FUNC0); /* GPIO1[12], LED3 */

	   Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2),1);
	   Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<14),1);
	   Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<11)|(1<<12),1);

	   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2));
	   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 0,(1<<14));
	   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<11)|(1<<12));

	/*Hardware GPIO initialization (leds, buttons ...)*/


   /* perform the needed initialization here */
   while(1) {
      /* add your code here */

       Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5, 1<<13);

       Chip_GPIO_SetValue(LPC_GPIO_PORT, 5, 1<<13);

   }
   return 0;
}
コード例 #7
0
ファイル: main.c プロジェクト: ernesto-g/prog_up_entregas
static void boardLedsInit(void) {
   
   /* Config EDU-CIAA-NXP Led Pins as GPIOs */
   Chip_SCU_PinMux(2,0,MD_PUP,FUNC4);  /* GPIO5[0],  LEDR */
   Chip_SCU_PinMux(2,1,MD_PUP,FUNC4);  /* GPIO5[1],  LEDG */
   Chip_SCU_PinMux(2,2,MD_PUP,FUNC4);  /* GPIO5[2],  LEDB */
   Chip_SCU_PinMux(2,10,MD_PUP,FUNC0); /* GPIO0[14], LED1 */
   Chip_SCU_PinMux(2,11,MD_PUP,FUNC0); /* GPIO1[11], LED2 */
   Chip_SCU_PinMux(2,12,MD_PUP,FUNC0); /* GPIO1[12], LED3 */

   /* Config EDU-CIAA-NXP Led Pins as Outputs */
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2),1);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<14),1);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<11)|(1<<12),1);

   /* Init EDU-CIAA-NXP Led Pins OFF */
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 0,(1<<14));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<11)|(1<<12));

}
コード例 #8
0
void ActivarLeds(int valor){
	if((valor & (1<<0))==(1<<0)){
		Chip_GPIO_SetValue(LPC_GPIO_PORT, 5,(1<<0));
	}else{
		Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<0));
	}
	if((valor & (1<<1))==(1<<1)){
			Chip_GPIO_SetValue(LPC_GPIO_PORT, 5,(1<<1));
		}else{
			Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<1));
		}
	if((valor & (1<<2))==(1<<2)){
			Chip_GPIO_SetValue(LPC_GPIO_PORT, 5,(1<<2));
		}else{
			Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<2));
		}
	if((valor & (1<<3))==(1<<3)){
			Chip_GPIO_SetValue(LPC_GPIO_PORT, 0,(1<<14));
		}else{
			Chip_GPIO_ClearValue(LPC_GPIO_PORT, 0,(1<<14));
		}
	if((valor & (1<<4))==(1<<4)){
			Chip_GPIO_SetValue(LPC_GPIO_PORT, 1,(1<<11));
		}else{
			Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<11));
		}
	if((valor & (1<<5))==(1<<5)){
			Chip_GPIO_SetValue(LPC_GPIO_PORT, 1,(1<<12));
		}else{
			Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<12));
		}

}
コード例 #9
0
/** @brief funcion que lee los datos del sensor DHT22
 * primero realiza la inicializacion con los tiempos especificados
 *
 *luego lee 40 bits de datos que envia el sensor
 *
 *@param dhthum parametro pasado como referencia donde se modificara el valor de la humedad
 *@param dhttemp parametro pasado como referencia donde se modificara el valor de la temperatura
 */
void leer_dht22(float *dhthum,float *dhttemp){
	    int dht_pin_in;
	    float dhth,dhtt;
	    int i;
	    byte dht22_dat[5],dht22_pin_checksum;
	    for(i=0;i<5;i++){
	    dht22_dat[i]=0;
	    }
	    //START SIGNAL
	    Chip_SCU_PinMux(dht22_port,dht22_pin,SCU_MODE_PULLUP | SCU_MODE_ZIF_DIS,FUNC0); //dth22 como output
		Chip_GPIO_SetDir(LPC_GPIO_PORT,dht22_gpioPort,(1<<dht22_gpioPin),!0);
		dht22_delay_us(20);

	    Chip_GPIO_ClearValue(LPC_GPIO_PORT,dht22_gpioPort,(1<<dht22_gpioPin));

		dht22_delay_ms(5);

	    Chip_GPIO_SetValue(LPC_GPIO_PORT,dht22_gpioPort,(1<<dht22_gpioPin));

	    dht22_delay_us(30);
		//WAIT RESPONSE
	    Chip_SCU_PinMux(dht22_port,dht22_pin,SCU_MODE_PULLUP  | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS,FUNC0);
	    Chip_GPIO_SetDir(LPC_GPIO_PORT,dht22_gpioPort,(1<<dht22_gpioPin),!1);//dth22 como input
	    dht_pin_in=Chip_GPIO_GetPinState(LPC_GPIO_PORT,dht22_gpioPort,dht22_gpioPin);
	    if(dht_pin_in){
	    	ciaaPOSIX_printf("Error de inicializacion nro 1");
	    }
	    dht22_delay_us(80);
	    dht_pin_in=Chip_GPIO_GetPinState(LPC_GPIO_PORT,dht22_gpioPort,dht22_gpioPin);
	    if(!dht_pin_in){
	    	 ciaaPOSIX_printf("Error de inicializacion nro 1");
	    }
	    dht22_delay_us(70);
	    for(i=0;i<5;i++){
	    	dht22_dat[i]=leer_datos_dht();

	    }
	    dht22_pin_checksum= dht22_pin_dat[0]+dht22_pin_dat[1]+dht22_pin_dat[2]+dht22_pin_dat[3];

	    if(dht22_pin_dat[4]!=dht22_pin_checksum){
	         ciaaPOSIX_printf("\r\nDHT checksum error");
	    }

	    dhth  = (dht22_dat[0]<<8) | dht22_dat[1];
	    dhth  /= 10;
	    dhtt  = (dht22_dat[2]<<8) | dht22_dat[3];
	    dhtt /= 10;
	    *dhttemp = dhtt;
	    *dhthum = dhth;
}
コード例 #10
0
void InicializaPuertosTeclasYLeds() {

    Chip_GPIO_Init(LPC_GPIO_PORT);
    Chip_SCU_PinMux(2,0,MD_PUP,FUNC4);  /* remapea P2_0  en GPIO5[0], LED0R y habilita el pull up*/
    Chip_SCU_PinMux(2,1,MD_PUP,FUNC4);  /* remapea P2_1  en GPIO5[1], LED0G y habilita el pull up */
    Chip_SCU_PinMux(2,2,MD_PUP,FUNC4);  /* remapea P2_2  en GPIO5[2], LED0B y habilita el pull up */
    Chip_SCU_PinMux(2,10,MD_PUP,FUNC0); /* remapea P2_10 en GPIO0[14], LED1 y habilita el pull up */
    Chip_SCU_PinMux(2,11,MD_PUP,FUNC0); /* remapea P2_11 en GPIO1[11], LED2 y habilita el pull up */
    Chip_SCU_PinMux(2,12,MD_PUP,FUNC0); /* remapea P2_12 en GPIO1[12], LED3 y habilita el pull up */

    Chip_SCU_PinMux(1,0,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* remapea P1_0  en GPIO 0[4], SW1 */
    Chip_SCU_PinMux(1,1,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* remapea P1_1  en GPIO 0[8], SW2 */
    Chip_SCU_PinMux(1,2,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* remapea P1_2  en GPIO 0[9], SW3 */
    Chip_SCU_PinMux(1,6,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* remapea P1_6  en GPIO 1[9], SW4 */


    Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2),1);
    Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<14),1);
    Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<11)|(1<<12),1);

    Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2));
    Chip_GPIO_ClearValue(LPC_GPIO_PORT, 0,(1<<14));
    Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<11)|(1<<12));
}
コード例 #11
0
ファイル: board.c プロジェクト: epernia/HVM
static void Board_LED_Init()
{
	Chip_SCU_PinMux(2,0,MD_PUP,FUNC4);  /* GPIO5[0], LED0R */
	Chip_SCU_PinMux(2,1,MD_PUP,FUNC4);  /* GPIO5[1], LED0G */
	Chip_SCU_PinMux(2,2,MD_PUP,FUNC4);  /* GPIO5[2], LED0B */
	Chip_SCU_PinMux(2,10,MD_PUP,FUNC0); /* GPIO0[14], LED1 */
	Chip_SCU_PinMux(2,11,MD_PUP,FUNC0); /* GPIO1[11], LED2 */
	Chip_SCU_PinMux(2,12,MD_PUP,FUNC0); /* GPIO1[12], LED3 */

	Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2),1);
	Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<14),1);
	Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<11)|(1<<12),1);

	Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2));
	Chip_GPIO_ClearValue(LPC_GPIO_PORT, 0,(1<<14));
	Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<11)|(1<<12));

	Board_LED_Set(0, 0);
	Board_LED_Set(1, 0);
	Board_LED_Set(2, 0);
	Board_LED_Set(3, 0);
	Board_LED_Set(4, 0);
	Board_LED_Set(5, 0);
}
コード例 #12
0
ファイル: ciaaDriverDio.c プロジェクト: alexking87/ciaa.team
/** \brief perform low level gpio initialization for LPC4337
 */
static void ciaa_lpc4337_gpio_init(void)
{
   Chip_GPIO_Init(LPC_GPIO_PORT);

#if (BOARD == ciaa_nxp)
   /* Inputs */
   Chip_SCU_PinMux(4,0,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO2[0]  */
   Chip_SCU_PinMux(4,1,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO2[1]  */
   Chip_SCU_PinMux(4,2,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO2[2]  */
   Chip_SCU_PinMux(4,3,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO2[3]  */
   Chip_SCU_PinMux(7,3,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO3[11] */
   Chip_SCU_PinMux(7,4,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO3[12] */
   Chip_SCU_PinMux(7,5,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO3[13] */
   Chip_SCU_PinMux(7,6,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO3[14] */

   Chip_GPIO_SetDir(LPC_GPIO_PORT, 2,0xF, 0);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 3, 0xF<<11, 0);

   /* MOSFETs */
   Chip_SCU_PinMux(4,8,MD_PUP|MD_EZI,FUNC4);  /* GPIO5[12] */
   Chip_SCU_PinMux(4,9,MD_PUP|MD_EZI,FUNC4);  /* GPIO5[13] */
   Chip_SCU_PinMux(4,10,MD_PUP|MD_EZI,FUNC4); /* GPIO5[14] */
   Chip_SCU_PinMux(1,5,MD_PUP|MD_EZI,FUNC0);  /* GPIO1[8]  */
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<12)|(1<<13)|(1<<14),1);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<8),1);
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<12)|(1<<13)|(1<<14));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<8));

   /* Relays */
   Chip_SCU_PinMux(4,4,MD_PUP|MD_EZI,FUNC0); /* GPIO2[4] */
   Chip_SCU_PinMux(4,5,MD_PUP|MD_EZI,FUNC0); /* GPIO2[5] */
   Chip_SCU_PinMux(4,6,MD_PUP|MD_EZI,FUNC0); /* GPIO2[6] */
   Chip_SCU_PinMux(2,1,MD_PUP|MD_EZI,FUNC4); /* GPIO5[1] */
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 2,(1<<4)|(1<<5)|(1<<6),1);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<1),1);
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 2,(1<<4)|(1<<5)|(1<<6));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<1));

   /* LV-TTL GPIOs (not used yet) */
   Chip_SCU_PinMux(6,1,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0/P6_1/GPIO3[0] */
   Chip_SCU_PinMux(2,5,MD_PUP|MD_EZI|MD_ZI,FUNC4); /* GPIO1/P2_5/GPIO5[5] */
#elif (BOARD == edu_ciaa_nxp)
   /* Switches */
   Chip_SCU_PinMux(1,0,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[4], SW1 */
   Chip_SCU_PinMux(1,1,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[8], SW2 */
   Chip_SCU_PinMux(1,2,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[9], SW3 */
   Chip_SCU_PinMux(1,6,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO1[9], SW4 */

   Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<4)|(1<<8)|(1<<9),0);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<9),0);

   /* LEDs */
   Chip_SCU_PinMux(2,0,MD_PUP|MD_EZI,FUNC4);  /* GPIO5[0], LED0R */
   Chip_SCU_PinMux(2,1,MD_PUP|MD_EZI,FUNC4);  /* GPIO5[1], LED0G */
   Chip_SCU_PinMux(2,2,MD_PUP|MD_EZI,FUNC4);  /* GPIO5[2], LED0B */
   Chip_SCU_PinMux(2,10,MD_PUP|MD_EZI,FUNC0); /* GPIO0[14], LED1 */
   Chip_SCU_PinMux(2,11,MD_PUP|MD_EZI,FUNC0); /* GPIO1[11], LED2 */
   Chip_SCU_PinMux(2,12,MD_PUP|MD_EZI,FUNC0); /* GPIO1[12], LED3 */

   Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2),1);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<14),1);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<11)|(1<<12),1);

   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 0,(1<<14));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<11)|(1<<12));

   /* Botonera matricial hecha en casa */

   /* outputs */	// {2,0},{2,1},{2,2},{2,3}

   Chip_SCU_PinMux(4,0,MD_PUP|MD_EZI,FUNC0); /* GPIO2[0], T_FIL0, P4_0 */
   Chip_SCU_PinMux(4,1,MD_PUP|MD_EZI,FUNC0); /* GPIO2[1], T_FIL1, P4_1 */
   Chip_SCU_PinMux(4,0,MD_PUP|MD_EZI,FUNC0); /* GPIO2[2], T_FIL2, P4_2 */
   Chip_SCU_PinMux(4,1,MD_PUP|MD_EZI,FUNC0); /* GPIO2[3], T_FIL3, P4_4 */

   Chip_GPIO_SetDir(LPC_GPIO_PORT, 2,(1<<0)|(1<<1)|(1<<2)|(1<<3),1);
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 2,(1<<0)|(1<<1)|(1<<2)|(1<<3));

   /* inputs */		// {1,8},{3,12},{3,13}

   Chip_SCU_PinMux(1,5,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO1[8], T_COL0, P1_5 */
   Chip_SCU_PinMux(7,4,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO3[12], T_COL1, P7_4 */
   Chip_SCU_PinMux(7,5,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO3[13], T_COL2, P7_5 */

   Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<8),0);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 3,(1<<12)|(1<<13),0);

   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<8));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 3,(1<<12)|(1<<13));

   // Ports Display {2,4},{2,5},{2,6},{5,14},{3,3},{5,13} OUTPUTS

	Chip_SCU_PinMux(4,4,MD_PUP,FUNC0); 			/* GPIO2[4], LCD1 */
	Chip_SCU_PinMux(4,5,MD_PUP,FUNC0);  		/* GPIO2[5], LCD2 */
	Chip_SCU_PinMux(4,6,MD_PUP,FUNC0);  		/* GPIO2[6], LCD3 */

	Chip_GPIO_SetDir(LPC_GPIO_PORT, 2,(1<<4)|(1<<5)|(1<<6),1);
	Chip_GPIO_ClearValue(LPC_GPIO_PORT, 2,(1<<4)|(1<<5)|(1<<6));

	Chip_SCU_PinMux(4,10,MD_PUP,FUNC4); 		/* GPIO5[14], LCD4 */
	Chip_SCU_PinMux(4,9,MD_PUP,FUNC4);  		/* GPIO5[13], LCD_EN */

	Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<14)|(1<<13),1);
	Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<14)|(1<<13));

	// PIN RS
	Chip_SCU_PinMux(6,4,MD_PUP,FUNC0);  		/* GPIO3[3], GPIO1 -> lcd_rs */
	Chip_GPIO_SetDir(LPC_GPIO_PORT, 3,(1<<3),1);
	Chip_GPIO_ClearValue(LPC_GPIO_PORT, 3,(1<<3));

#else
   #error please define BOARD variable!
#endif
}
コード例 #13
0
/** \brief Main function
 *
 * This is the main entry point of the software.
 *
 * \returns 0
 *
 * \remarks This function never returns. Return value is only to avoid compiler
 *          warnings or errors.
 */
int main(void)
{


	   /*Put initializations in a separate function hw_init(void) or something like that...*/

	   Chip_SCU_PinMux(1,0,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[4], SW1 */
	   Chip_SCU_PinMux(1,1,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[8], SW2 */
	   Chip_SCU_PinMux(1,2,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[9], SW3 */
	   Chip_SCU_PinMux(1,6,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO1[9], SW4 */

	   Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<4)|(1<<8)|(1<<9),0);
	   Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<9),0);

	   /* LEDs */
	   Chip_SCU_PinMux(2,0,MD_PUP,FUNC4);  /* GPIO5[0], LED0R */
	   Chip_SCU_PinMux(2,1,MD_PUP,FUNC4);  /* GPIO5[1], LED0G */
	   Chip_SCU_PinMux(2,2,MD_PUP,FUNC4);  /* GPIO5[2], LED0B */
	   Chip_SCU_PinMux(2,10,MD_PUP,FUNC0); /* GPIO0[14], LED1 */
	   Chip_SCU_PinMux(2,11,MD_PUP,FUNC0); /* GPIO1[11], LED2 */
	   Chip_SCU_PinMux(2,12,MD_PUP,FUNC0); /* GPIO1[12], LED3 */

	   Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2),1);
	   Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<14),1);
	   Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<11)|(1<<12),1);

	   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2));
	   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 0,(1<<14));
	   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<11)|(1<<12));

	/*Hardware GPIO initialization (leds, buttons ...)*/


	   /*UART initialization*/

	   /* UART0 (RS485/Profibus) */
	   Chip_UART_Init(LPC_USART0);
	   Chip_UART_SetBaud(LPC_USART0, 115200);

	   Chip_UART_SetupFIFOS(LPC_USART0, UART_FCR_FIFO_EN | UART_FCR_TRG_LEV0);

	   Chip_UART_TXEnable(LPC_USART0);

	   Chip_SCU_PinMux(9, 5, MD_PDN, FUNC7);              /* P9_5: UART0_TXD */
	   Chip_SCU_PinMux(9, 6, MD_PLN|MD_EZI|MD_ZI, FUNC7); /* P9_6: UART0_RXD */

	   Chip_UART_SetRS485Flags(LPC_USART0, UART_RS485CTRL_DCTRL_EN | UART_RS485CTRL_OINV_1);

	   Chip_SCU_PinMux(6, 2, MD_PDN, FUNC2);              /* P6_2: UART0_DIR */

	   /* UART2 (USB-UART) */
	   Chip_UART_Init(LPC_USART2);
	   Chip_UART_SetBaud(LPC_USART2, 115200);

	   Chip_UART_SetupFIFOS(LPC_USART2, UART_FCR_FIFO_EN | UART_FCR_TRG_LEV0);

	   Chip_UART_TXEnable(LPC_USART2);

	   Chip_SCU_PinMux(7, 1, MD_PDN, FUNC6);              /* P7_1: UART2_TXD */
	   Chip_SCU_PinMux(7, 2, MD_PLN|MD_EZI|MD_ZI, FUNC6); /* P7_2: UART2_RXD */

	   /* UART3 (RS232) */
	   Chip_UART_Init(LPC_USART3);
	   Chip_UART_SetBaud(LPC_USART3, 115200);

	   Chip_UART_SetupFIFOS(LPC_USART3, UART_FCR_FIFO_EN | UART_FCR_TRG_LEV0);

	   Chip_UART_TXEnable(LPC_USART3);

	   Chip_SCU_PinMux(2, 3, MD_PDN, FUNC2);              /* P2_3: UART3_TXD */
	   Chip_SCU_PinMux(2, 4, MD_PLN|MD_EZI|MD_ZI, FUNC2); /* P2_4: UART3_RXD */



       /*Chip_UART_IntDisable((LPC_USART_T *)LPC_USART2, UART_IER_THREINT);*/
       /* this one calls write */
       /*ciaaDriverUart_txConfirmation(device);*/
       /* enable THRE irq (TX) */
/*       Chip_UART_IntEnable((LPC_USART_T *)LPC_USART2, UART_IER_THREINT);*/

      uint64_t j;
	  uint8_t size = 28;
	  uint8_t i = 0;
	  uint8_t data = 0;

	  char message[] = "Follow the white rabbit...\n\r";

	  /*	  just send the F  ...! */
	 /*	   Chip_UART_Send((LPC_USART_T *) LPC_USART2, message, index); */

	  /*looking for a 'a' character*/
   /* perform the needed initialization here */
   while(1) {
      /* do nothing */
		  data = i = 0;

		  /*wait for keyboard character*/

		  while (data == 0)
		  {
			  data = Chip_UART_ReadByte((LPC_USART_T *)LPC_USART2);

			switch (data){
			case 'r':
				  /*Toggle Red Led*/
			 	  Chip_GPIO_SetPortToggle(LPC_GPIO_PORT,LED2_PORT,LED_2);
				break;
			case 'v':
				  /*Toggle Green Led*/
			 	  Chip_GPIO_SetPortToggle(LPC_GPIO_PORT,LED3_PORT,LED_3);
				break;
			case 'a':
				  /*Toggle Yellow Led*/
			 	  Chip_GPIO_SetPortToggle(LPC_GPIO_PORT,LED1_PORT,LED_1);
				break;
			default:
				data = 0;
			}
		  }

 	     /*Send string*/
		 while(((Chip_UART_ReadLineStatus((LPC_USART_T *)LPC_USART2) & UART_LSR_THRE) != 0) && (i < size))
	      {
	         /* send first byte */
	         Chip_UART_SendByte((LPC_USART_T *)LPC_USART2, message[i]);
	         /* bytes written */

	         /*delay*/
	         for (j=0;j<50000;j++){
	           asm  ("nop");
	           }
	         i++;
	      }
   }
   return 0;
}
コード例 #14
0
/** \brief perform low level gpio initialization for LPC4337
 */
static void ciaa_lpc4337_gpio_init(void)
{
   Chip_GPIO_Init(LPC_GPIO_PORT);

#if (BOARD == ciaa_nxp)
   /* Inputs */
   Chip_SCU_PinMux(4,0,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO2[0]  */
   Chip_SCU_PinMux(4,1,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO2[1]  */
   Chip_SCU_PinMux(4,2,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO2[2]  */
   Chip_SCU_PinMux(4,3,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO2[3]  */
   Chip_SCU_PinMux(7,3,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO3[11] */
   Chip_SCU_PinMux(7,4,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO3[12] */
   Chip_SCU_PinMux(7,5,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO3[13] */
   Chip_SCU_PinMux(7,6,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO3[14] */

   Chip_GPIO_SetDir(LPC_GPIO_PORT, 2,0xF, 0);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 3, 0xF<<11, 0);

   /* MOSFETs */
   Chip_SCU_PinMux(4,8,MD_PUP|MD_EZI,FUNC4);  /* GPIO5[12] */
   Chip_SCU_PinMux(4,9,MD_PUP|MD_EZI,FUNC4);  /* GPIO5[13] */
   Chip_SCU_PinMux(4,10,MD_PUP|MD_EZI,FUNC4); /* GPIO5[14] */
   Chip_SCU_PinMux(1,5,MD_PUP|MD_EZI,FUNC0);  /* GPIO1[8]  */
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<12)|(1<<13)|(1<<14),1);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<8),1);
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<12)|(1<<13)|(1<<14));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<8));

   /* Relays */
   Chip_SCU_PinMux(4,4,MD_PUP|MD_EZI,FUNC0); /* GPIO2[4] */
   Chip_SCU_PinMux(4,5,MD_PUP|MD_EZI,FUNC0); /* GPIO2[5] */
   Chip_SCU_PinMux(4,6,MD_PUP|MD_EZI,FUNC0); /* GPIO2[6] */
   Chip_SCU_PinMux(2,1,MD_PUP|MD_EZI,FUNC4); /* GPIO5[1] */
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 2,(1<<4)|(1<<5)|(1<<6),1);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<1),1);
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 2,(1<<4)|(1<<5)|(1<<6));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<1));

   /* LV-TTL GPIOs (not used yet) */
   Chip_SCU_PinMux(6,1,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0/P6_1/GPIO3[0] */
   Chip_SCU_PinMux(2,5,MD_PUP|MD_EZI|MD_ZI,FUNC4); /* GPIO1/P2_5/GPIO5[5] */
#elif (BOARD == edu_ciaa_nxp)
   /* Switches */
   Chip_SCU_PinMux(1,0,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[4], SW1 */
   Chip_SCU_PinMux(1,1,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[8], SW2 */
   Chip_SCU_PinMux(1,2,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[9], SW3 */
   Chip_SCU_PinMux(1,6,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO1[9], SW4 */

   Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<4)|(1<<8)|(1<<9),0);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<9),0);

   /* LEDs */
   Chip_SCU_PinMux(2,0,MD_PUP|MD_EZI,FUNC4);  /* GPIO5[0], LED0R */
   Chip_SCU_PinMux(2,1,MD_PUP|MD_EZI,FUNC4);  /* GPIO5[1], LED0G */
   Chip_SCU_PinMux(2,2,MD_PUP|MD_EZI,FUNC4);  /* GPIO5[2], LED0B */
   Chip_SCU_PinMux(2,10,MD_PUP|MD_EZI,FUNC0); /* GPIO0[14], LED1 */
   Chip_SCU_PinMux(2,11,MD_PUP|MD_EZI,FUNC0); /* GPIO1[11], LED2 */
   Chip_SCU_PinMux(2,12,MD_PUP|MD_EZI,FUNC0); /* GPIO1[12], LED3 */

   Chip_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2),1);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<14),1);
   Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<11)|(1<<12),1);

   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 0,(1<<14));
   Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1,(1<<11)|(1<<12));

#else
   #error please define BOARD variable!
#endif
}