void inicializarled() { 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_GPIO_SetDir(LPC_GPIO_PORT,5,(1<<0)|(1<<1)|(1<<2),1); // Defino ls puertos como salidas Chip_GPIO_SetDir(LPC_GPIO_PORT,0,(1<<14),1); Chip_GPIO_SetDir(LPC_GPIO_PORT,1,(1<<11)|(1<<12),1); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT,5,0); // reseteo todos los leds Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT,5,1); // reseteo todos los leds Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT,5,2); // reseteo todos los leds Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT,0,14); // reseteo todos los leds Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT,1,11); // reseteo todos los leds Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT,1,14); // reseteo todos los leds }
void InicGPIOs ( void ) { Chip_GPIO_SetDir(LPC_GPIO,LEDXpresso,SALIDA); Chip_GPIO_WritePortBit(LPC_GPIO,LEDXpresso,1); Chip_GPIO_SetDir(LPC_GPIO,DHT_DATA,ENTRADA); }
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)); }
/** \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. */ void InicializarLeds(void){ /*Funcion inicializa GPIO */ Chip_GPIO_Init(LPC_GPIO_PORT); /**Configurar la System Control Unit (SCU), para indicarle las características eléctricas de cada pin empleado y remapearlos como puertos GPIO**/ 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 */ /********************************************************************/ /*Seleccionar el modo (salida) de cada pin con la función "chip_GPIO_setDIr"*/ /*******************************************************************/ /*Defino salida LED_R (0),LED_G (1) y LED_B (2)*/ Chip_GPIO_SetDir(LPC_GPIO_PORT,5,(((1<<0)|(1<<1))|(1<<2)),1); /*Defino salida LED1 (14)*/ Chip_GPIO_SetDir(LPC_GPIO_PORT,0,(1<<14),1); /*Defino salida LED2 (11) y LED3(12)*/ Chip_GPIO_SetDir(LPC_GPIO_PORT,1,((1<<11)|(1<<12)),1); /****************************************************/ }
int main(void) { SystemCoreClockUpdate(); Board_Init(); Board_LED_Set(0, false); // SW4 setup Chip_GPIO_SetDir(LPC_GPIO, 1, 31, false); sw4 = debounce_add(DEBOUNCE_TIME / DEBOUNCE_CYCLE, is_sw4_pushed, NULL); // RGB Rojo Chip_GPIO_SetDir(LPC_GPIO, 2, 0, true); // RGB Verde Chip_GPIO_SetDir(LPC_GPIO, 2, 1, true); // RGB Azul Chip_GPIO_SetDir(LPC_GPIO, 0, 26, true); queue_init(&queue, 1, EventQueue, AlarmTimeoutPush, AlarmTimeoutPop, MutexQueue); StartOS(AppMode1); while (1) { } return 0; }
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); }
void Board_Buttons_Init(void) // FIXME not functional ATM { 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); }
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; }
void switchsInit(){ Chip_SCU_PinMux(PACKSWITCHS,SW1_PIN,MD_PUP|MD_EZI|MD_ZI,FUNC0); Chip_SCU_PinMux(PACKSWITCHS,SW2_PIN,MD_PUP|MD_EZI|MD_ZI,FUNC0); Chip_SCU_PinMux(PACKSWITCHS,SW3_PIN,MD_PUP|MD_EZI|MD_ZI,FUNC0); Chip_SCU_PinMux(PACKSWITCHS,SW4_PIN,MD_PUP|MD_EZI|MD_ZI,FUNC0); Chip_GPIO_SetDir(LPC_GPIO_PORT,PORT0,SW1_MASK,INPUT); Chip_GPIO_SetDir(LPC_GPIO_PORT,PORT0,SW2_MASK,INPUT); Chip_GPIO_SetDir(LPC_GPIO_PORT,PORT0,SW3_MASK,INPUT); Chip_GPIO_SetDir(LPC_GPIO_PORT,PORT1,SW4_MASK,INPUT); }
static void boardButtonsInit(void) { /* Config EDU-CIAA-NXP Button Pins as GPIOs */ Chip_SCU_PinMux(1,0,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[4], TEC1 */ Chip_SCU_PinMux(1,1,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[8], TEC2 */ Chip_SCU_PinMux(1,2,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO0[9], TEC3 */ Chip_SCU_PinMux(1,6,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* GPIO1[9], TEC4 */ /* Config EDU-CIAA-NXP Button Pins as Inputs */ Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<4)|(1<<8)|(1<<9),0); Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<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; }
/* Sets up system hardware */ static void prvSetupHardware(void) { SystemCoreClockUpdate(); Board_Init(); /* Inicialización de periféricos */ // RGB Rojo Chip_GPIO_SetDir(LPC_GPIO, 2, 0, true); // RGB Verde Chip_GPIO_SetDir(LPC_GPIO, 2, 1, true); // SW4 Chip_GPIO_SetDir(LPC_GPIO, 1, 31, false); }
void InicializarTeclas(void) { Chip_GPIO_Init(LPC_GPIO_PORT); 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, 0, (1 << 4), 0); Chip_GPIO_SetDir(LPC_GPIO_PORT, 0, (1 << 8), 0); Chip_GPIO_SetDir(LPC_GPIO_PORT, 0, (1 << 9), 0); Chip_GPIO_SetDir(LPC_GPIO_PORT, 1, (1 << 9), 0); }
void inicializarTeclas(void) { /* inicializo*/ Chip_GPIO_Init(LPC_GPIO_PORT); /* inicializo pulsadores */ 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 */ /* seteo los pulsadores como puerto de entrada */ Chip_GPIO_SetDir(LPC_GPIO_PORT, 0, (1<<4)|(1<<9)|(1<<8), 0); Chip_GPIO_SetDir(LPC_GPIO_PORT, 1, (1<<9), 0); }
void Board_Sensors_Init(void) { Chip_SCU_PinMux(gpioSw1.portNumber,gpioSw1.portPin,MD_PUP|MD_EZI|MD_ZI,gpioSw1.func); /* GPIO0[4], TEC1 */ Chip_GPIO_SetDir(LPC_GPIO_PORT, gpioSw1.gpioNumber,(1<<gpioSw1.gpioPin),0); Chip_SCU_PinMux(gpioSw2.portNumber,gpioSw2.portPin,MD_PUP|MD_EZI|MD_ZI,gpioSw2.func); /* GPIO0[4], TEC2 */ Chip_GPIO_SetDir(LPC_GPIO_PORT, gpioSw2.gpioNumber,(1<<gpioSw2.gpioPin),0); Chip_SCU_PinMux(gpioSw3.portNumber,gpioSw3.portPin,MD_PUP|MD_EZI|MD_ZI,gpioSw3.func); /* GPIO0[4], TEC3 */ Chip_GPIO_SetDir(LPC_GPIO_PORT, gpioSw3.gpioNumber,(1<<gpioSw3.gpioPin),0); Chip_SCU_PinMux(gpioSw4.portNumber,gpioSw4.portPin,MD_PUP|MD_EZI|MD_ZI,gpioSw4.func); /* GPIO0[4], TEC4 */ Chip_GPIO_SetDir(LPC_GPIO_PORT, gpioSw4.gpioNumber,(1<<gpioSw4.gpioPin),0); }
void InicializarTeclas(){ /* inicializa el puerto GPIO */ Chip_GPIO_Init(LPC_GPIO_PORT); /* Configura Multiplexor: Chip_SCU_PinMux (Puerto, Pin específico, Modo, Función del pin)*/ Chip_SCU_PinMux(PUERTO_TECLA_1,PIN_TECLA_1,MD_PUP|MD_EZI|MD_ZI,FUNC0 ); Chip_SCU_PinMux(PUERTO_TECLA_2,PIN_TECLA_2,MD_PUP|MD_EZI|MD_ZI,FUNC0); Chip_SCU_PinMux(PUERTO_TECLA_3,PIN_TECLA_3,MD_PUP|MD_EZI|MD_ZI,FUNC0); Chip_SCU_PinMux(PUERTO_TECLA_4,PIN_TECLA_4,MD_PUP|MD_EZI|MD_ZI,FUNC0); /* Setea puertos como Entrada: Chip_GPIO_SetDir (Puerto GPIO, GPIO específico, Bit de Tecla, Sentido)*/ Chip_GPIO_SetDir(LPC_GPIO_PORT,GPIO_TECLA_1,BIT_TECLA_1,ENTRADA); Chip_GPIO_SetDir(LPC_GPIO_PORT,GPIO_TECLA_2,BIT_TECLA_2,ENTRADA); Chip_GPIO_SetDir(LPC_GPIO_PORT,GPIO_TECLA_3,BIT_TECLA_3,ENTRADA); Chip_GPIO_SetDir(LPC_GPIO_PORT,GPIO_TECLA_4,BIT_TECLA_4,ENTRADA); }
void configurar_salidas(void) { //Configurar el pin GPIO8 (P6_12) //La FUNC0 de GPIO8 es GPIO2[8] //Definicion de datos uint8 pinNamePort = 6; uint8 pinNamePin = 12; uint8 func = FUNC0; uint8 gpioPort = 2; uint8 gpioPin = 8; //Configuración como OUTPUT: Chip_SCU_PinMux( pinNamePort, pinNamePin, SCU_MODE_INACT | SCU_MODE_ZIF_DIS, func ); uint8_t OUTPUT = 1; Chip_GPIO_SetDir(LPC_GPIO_PORT, gpioPort, ( 1 << gpioPin ), OUTPUT); }
/*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)); }
/*==================[internal functions definition]==========================*/ void InicializarTecla(void) { Chip_GPIO_Init(LPC_GPIO_PORT); //Chip_SCU_PinMux(TECLA_PAQUETE,TEC1_PIN,MD_PUP,FUNC0);/*mapea P2 0 en GPIO5[0], LED0R y habilita el pull up */ //Chip_SCU_PinMux(TECLA_PAQUETE,TEC2_PIN,MD_PUP,FUNC0); /*mapea P2 1 en GPIO5[1], LED0G y habilita el pull up */ //Chip_SCU_PinMux(TECLA_PAQUETE,TEC3_PIN,MD_PUP,FUNC0); /* mapea P2 2 en GPIO5[2], LED0B y habilita el pull up */ //Chip_SCU_PinMux(TECLA_PAQUETE,TEC4_PIN,MD_PUP,FUNC0); /* remapea P2 10 en GPIO0[14], LED1 y habilita el pull up */ Chip_SCU_PinMux(TECLA_PAQUETE,TEC1_PIN,MD_PUP|MD_EZI|MD_ZI,FUNC0);/* mapea P1 0 en GPIO 0[4], SW1 */ Chip_SCU_PinMux(TECLA_PAQUETE,TEC2_PIN,MD_PUP|MD_EZI|MD_ZI,FUNC0);/* mapea P1 1 en GPIO 0[8], SW2 */ Chip_SCU_PinMux(TECLA_PAQUETE,TEC3_PIN,MD_PUP|MD_EZI|MD_ZI,FUNC0);/* mapea P1 2 en GPIO 0[9], SW3 */ Chip_SCU_PinMux(TECLA_PAQUETE,TEC4_PIN,MD_PUP|MD_EZI|MD_ZI,FUNC0);/* mapea P1 6 en GPIO 1[9], SW4 */ Chip_GPIO_SetDir(LPC_GPIO_PORT, PORT_NUM_TEC12Y3, 1<<4|1<<8|1<<9, INPUT);/* bit*/ Chip_GPIO_SetDir(LPC_GPIO_PORT, PORT_NUM_TEC4,1<<9, INPUT); }
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)); }
static void prvSetupHardware(void) { SystemCoreClockUpdate(); Board_Init(); // led del stick Board_LED_Set(0, false); // SW4 Chip_GPIO_SetDir(LPC_GPIO, 1, 31, false); }
/* Sets up system hardware */ static void prvSetupHardware(void) { SystemCoreClockUpdate(); Board_Init(); /* Initial LED0 state is off */ Board_LED_Set(0, false); // SW4 Chip_GPIO_SetDir(LPC_GPIO, 1, 31, false); }
/** \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; }
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)); }
/** \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. */ void InicializarLeds(void) { Chip_GPIO_Init(LPC_GPIO_PORT); Chip_SCU_PinMux(2,10,MD_PUP,FUNC0); Chip_SCU_PinMux(2,11,MD_PUP,FUNC0); Chip_SCU_PinMux(2,12,MD_PUP,FUNC0); Chip_GPIO_SetDir(LPC_GPIO_PORT,0,1<<14, 1); // 100000000000000 Chip_GPIO_SetDir(LPC_GPIO_PORT,1,(1<<11)|(1<<12), 1); Chip_SCU_PinMux(2,0,MD_PUP,FUNC4); Chip_SCU_PinMux(2,1,MD_PUP,FUNC4); Chip_SCU_PinMux(2,2,MD_PUP,FUNC4); Chip_GPIO_SetDir(LPC_GPIO_PORT,5,(1<<0)|(1<<1)|(1<<2), 1); Chip_GPIO_SetDir(LPC_GPIO_PORT,5,1<<2, 1); Chip_GPIO_SetDir(LPC_GPIO_PORT,5,1<<2, 1); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT,0,14); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT,1,11); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT,1,12); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT,5,0); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT,5,1); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT,5,2); }
void inicia_led(void) { Chip_GPIO_Init(LPC_GPIO_PORT); //led R Chip_SCU_PinMux(2, 0, MD_PLN, FUNC4); Chip_GPIO_SetDir(LPC_GPIO_PORT, 5 , 1 , 1); //led G Chip_SCU_PinMux(2, 1, MD_PLN, FUNC4); Chip_GPIO_SetDir(LPC_GPIO_PORT, 5 , 1<<1 , 1); //led B Chip_SCU_PinMux(2, 2, MD_PLN, FUNC4); Chip_GPIO_SetDir(LPC_GPIO_PORT, 5 , 1<<2 , 1); //led 1 Amarillo Chip_SCU_PinMux(2, 10, MD_PLN, FUNC0); Chip_GPIO_SetDir(LPC_GPIO_PORT, 0 , 1<<14 , 1); //led 2 Rojo Chip_SCU_PinMux(2, 11, MD_PLN, FUNC0); Chip_GPIO_SetDir(LPC_GPIO_PORT, 1 , 1<<11 , 1); //led 3 Verde Chip_SCU_PinMux(2, 12, MD_PLN, FUNC0); Chip_GPIO_SetDir(LPC_GPIO_PORT, 1 , 1<<12 , 1);//salida //Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 0 , 14); //Gpio 5, BIT "1" pin P2_1(es solo un Nombre que se le da a un PIn del uC) Pagina397 //Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 5 , 1); }
void InicializarLEDS(){ Chip_GPIO_Init(LPC_GPIO_PORT); //Mapeo los ledsa los GPIOX.X y habilito pullup Chip_SCU_PinMux(2,0,MD_PUP,FUNC4); //mapea 2.0 a GPIO5[0] (RGB, R) Chip_SCU_PinMux(2,1,MD_PUP,FUNC4); //mapea 2.0 a GPIO5[1] (RGB, G) Chip_SCU_PinMux(2,2,MD_PUP,FUNC4); //mapea 2.0 a GPIO5[2] (RGB, B) Chip_SCU_PinMux(2,10,MD_PUP,FUNC0); //mapea 2.0 a GPIO0[14] (LED Amarillo) Chip_SCU_PinMux(2,11,MD_PUP,FUNC0); //mapea 2.0 a GPIO1[11] (LED Rojo) Chip_SCU_PinMux(2,12,MD_PUP,FUNC0); //mapea 2.0 a GPIO1[12] (LED Verde) //Direcciono los GPIOX.X Chip_GPIO_SetDir(LPC_GPIO_PORT, 5, (1<<0), 1); // !1 es SALIDA, LPC_GPIO_PORT Chip_GPIO_SetDir(LPC_GPIO_PORT, 5, (1<<1), 1); Chip_GPIO_SetDir(LPC_GPIO_PORT, 5, (1<<2), 1); Chip_GPIO_SetDir(LPC_GPIO_PORT, 0, (1<<14), 1); Chip_GPIO_SetDir(LPC_GPIO_PORT, 1, (1<<11), 1); Chip_GPIO_SetDir(LPC_GPIO_PORT, 1, (1<<12), 1); //Pongo en bajo las salidas GPIOX.X Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 5, 0); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 5, 1); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 5, 2); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 0, 14); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 1, 11); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 1, 12); }
void inicia_led(void) { //Led R Chip_SCU_PinMux(2, 0, MD_PLN, FUNC4); Chip_GPIO_SetDir(LPC_GPIO_PORT, 5 , 1 , 1); //Led G Chip_SCU_PinMux(2, 1, MD_PLN, FUNC4); Chip_GPIO_SetDir(LPC_GPIO_PORT, 5 , 1<<1 , 1); //Led B Chip_SCU_PinMux(2, 2, MD_PLN, FUNC4); Chip_GPIO_SetDir(LPC_GPIO_PORT, 5 , 1<<2 , 1); //Led 1 Amarillo Chip_SCU_PinMux(2, 10, MD_PLN, FUNC0); Chip_GPIO_SetDir(LPC_GPIO_PORT, 0 , 1<<14 , 1); //Led 2 Rojo Chip_SCU_PinMux(2, 11, MD_PLN, FUNC0); Chip_GPIO_SetDir(LPC_GPIO_PORT, 1 , 1<<11 , 1); //Led 3 Verde Chip_SCU_PinMux(2, 12, MD_PLN, FUNC0); Chip_GPIO_SetDir(LPC_GPIO_PORT, 1 , 1<<12 , 1); }
/* * Configurar Entrada */ void configurar_entrada(uint8_t pinNamePort,uint8_t pinNamePin,uint8_t func,uint8_t gpioPort,uint8_t gpioPin) { // Configuración como INPUT Chip_SCU_PinMux( pinNamePort, pinNamePin, SCU_MODE_PULLDOWN | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS, func ); uint8_t INPUT = 0; Chip_GPIO_SetDir(LPC_GPIO_PORT, gpioPort, (1 << gpioPin), INPUT); }
void inicializacion_de_led (void) { 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_GPIO_SetDir(LPC_GPIO_PORT, 5,(1<<0)|(1<<1)|(1<<2),1); /* aqui al puerto 5 le estoy dando a los bit 0, 1 y 2 (q son los led) los estoy inicializando como salida*/ Chip_GPIO_SetDir(LPC_GPIO_PORT, 0,(1<<14),1); Chip_GPIO_SetDir(LPC_GPIO_PORT, 1,(1<<11)|(1<<12),1); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 5, 0); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 5, 1); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 5, 2); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 0, 14); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 1, 11); Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 1, 12); }