Esempio n. 1
0
/** \brief TODO init_UART_RS485_EDUCIAA Initialization method  */
uint8_t init_UART_RS485_EDUCIAA(void)
{
	/** \details
	 * TODO description init_UART_RS485_EDUCIAA
	 *
	 * \param none
	 *
	 * \return uint8_t: TBD (to support errors in the init function)
	 * */

	/*  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 */

	return TRUE;
}
Esempio n. 2
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);
}
Esempio n. 3
0
/** \brief TODO init_UART_RS232_EDUCIAA Initialization method  */
uint8_t init_UART_RS232_EDUCIAA(void)
{
	/** \details
	 * TODO description init_UART_RS232_EDUCIAA
	 *
	 * \param none
	 *
	 * \return uint8_t: TBD (to support errors in the init function)
	 * */

	/* UART initialization*/

	/** 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 */

	return TRUE;
}
void initUSART_USB(uint32_t baud){
    /* Configuracion del Sistem Control Unit, para hacer uso de USB*/
	Chip_SCU_PinMux(UM_PORT7,PIN_RX_U2, MD_PLN | MD_EZI | MD_ZI, FUNC6);
    Chip_SCU_PinMux(UM_PORT7,PIN_TX_U2, MD_PLN, FUNC6);

    Chip_UART_Init(LPC_USART2);
    Chip_UART_SetBaud(LPC_USART2, baud);
    Chip_UART_SetupFIFOS(LPC_USART2, UART_FCR_FIFO_EN | UART_LCR_WLEN8 | UART_LCR_SBS_1BIT | UART_LCR_PARITY_DIS | UART_FCR_TRG_LEV0);
    Chip_UART_TXEnable(LPC_USART2);
}
Esempio n. 5
0
File: board.c Progetto: epernia/HVM
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);
}
Esempio n. 6
0
void configurar_UART(void)
{

	Chip_SCU_PinMux(7,1,MD_PDN,FUNC6);
	Chip_SCU_PinMux(7,2,MD_PLN|MD_EZI|MD_ZI, FUNC6);
	Chip_UART_Init(LPC_USART2);
	Chip_UART_SetBaud(LPC_USART2, 9600);
	Chip_UART_SetupFIFOS(LPC_USART2, UART_FCR_FIFO_EN | UART_FCR_TRG_LEV0);
	Chip_UART_TXEnable(LPC_USART2);
}
Esempio n. 7
0
//================================================[UART Management]==========================================================
void Board_UART_Init(LPC_USART_T *pUART)
{
	if(pUART==LPC_USART0)
	{
		/* 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 */
		uart0RxBufferData.buffer = NULL;
		uart0RxBufferData.size=0;
		uart0RxBufferData.index=0;
		uart0RxBufferData.flagNewPacket=0;
		uart0RxBufferData.timeoutCounter=0;
        	//NVIC_SetPriority(USART0_IRQn, 1);
        	//NVIC_EnableIRQ(USART0_IRQn);

	}
	else if(pUART==LPC_USART3)
	{
		/* 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 */
		uart3RxBufferData.buffer = NULL;
                uart3RxBufferData.size=0;
                uart3RxBufferData.index=0;
		uart3RxBufferData.flagNewPacket=0;
                uart3RxBufferData.timeoutCounter=0;

                //NVIC_SetPriority(USART3_IRQn, 1);
                //NVIC_EnableIRQ(USART3_IRQn);
	}
	/* Restart FIFOS: set Enable, Reset content, set trigger level */
   	Chip_UART_SetupFIFOS(pUART, UART_FCR_FIFO_EN | UART_FCR_TX_RS | UART_FCR_RX_RS | UART_FCR_TRG_LEV0);
   	/* dummy read */
   	Chip_UART_ReadByte(pUART);
   	/* enable rx interrupt */
   	Chip_UART_IntEnable(pUART, UART_IER_RBRINT);
}
Esempio n. 8
0
void ciaaUARTInit(void)
{
	/* UART0 (RS485/Profibus) */
	Chip_UART_Init(LPC_USART0);
	Chip_UART_SetBaud(LPC_USART0, 115200);

	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 */

	/* Restart FIFOS: set Enable, Reset content, set trigger level */
	Chip_UART_SetupFIFOS(LPC_USART0, UART_FCR_FIFO_EN | UART_FCR_TX_RS | UART_FCR_RX_RS | UART_FCR_TRG_LEV0);
	/* dummy read */
	Chip_UART_ReadByte(LPC_USART0);
	/* enable rx interrupt */
	Chip_UART_IntEnable(LPC_USART0, UART_IER_RBRINT);

	NVIC_EnableIRQ(USART0_IRQn);

	RingBuffer_Init(uarts[0].rrb, rxbuf[0], 1, UART_BUF_SIZE);
	RingBuffer_Init(uarts[0].trb, txbuf[0], 1, UART_BUF_SIZE);

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

	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 */

	Chip_UART_IntEnable(LPC_USART2, UART_IER_RBRINT);
	NVIC_EnableIRQ(USART2_IRQn);

	RingBuffer_Init(uarts[1].rrb, rxbuf[1], 1, UART_BUF_SIZE);
	RingBuffer_Init(uarts[1].trb, txbuf[1], 1, UART_BUF_SIZE);

	/* UART3 (RS232) */
//	Chip_UART_Init(LPC_USART3);
//	Chip_UART_SetBaud(LPC_USART3, 9600);
//
//	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 */
//
//	NVIC_EnableIRQ(USART3_IRQn);
//
}
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;


}
Esempio n. 10
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);
}
Esempio n. 11
0
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);

}
Esempio n. 12
0
int main(void) {

	uint32_t prompt = 0, rdCnt = 0;

	volatile bool start_trigger = false;

#if defined (M0_SLAVE_PAUSE_AT_MAIN)
	// Pause execution until debugger attaches and modifies variable
	while (pause_at_main == 0) {
	}
#endif

	init_g_vInitHardware();
//	usb_g_vInit();
	// init the interface
	SGPIO_spiInit();
//	ipc_g_vInit();

	// set direction of u4
	Chip_SCU_PinMux(2, 10, SCU_MODE_PULLUP, SCU_MODE_FUNC0);
	Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 14);
	Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 0, 14);
	//SysTick_Config(120000000/1000);

	//  CS_Pin
	Chip_SCU_PinMux(0, 1, SCU_MODE_PULLUP, SCU_MODE_FUNC0);
	Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 1);
	Chip_GPIO_SetPinOutHigh(LPC_GPIO_PORT, 0, 1);

//	radar_g_vDefaultInit();

	while (1) {


//		if (start_trigger) {
//			radar_mg_vPLLRampUp();
//			radar_mg_vPLLActivateModulation();
//			for (uint32_t i = 0; i < 40000000; i++)
//				;
//			radar_mg_vPLLDeactivateModulation();
//			radar_mg_vPLLRampDown();
//			radar_mg_vPLLActivateModulation();
//			for (uint32_t i = 0; i < 40000000; i++)
//				;
//			radar_mg_vPLLDeactivateModulation();
//
//		}
	}
		while(1);

}
/** @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;
}
Esempio n. 14
0
void Teclaon(void)
{

	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 */

}
Esempio n. 15
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);

}
Esempio n. 16
0
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);
}
Esempio n. 18
0
void Inicializar_UART(void)
{
//Configuramos la función del pint de la UART2 para que se conecte con la FTDI P7_1 (tx) y P7_2 (rx)
Chip_SCU_PinMux(_PAQUETE_PIN_UART2,_PIN_UART2_TX, MD_PDN, FUNC6);
Chip_SCU_PinMux(_PAQUETE_PIN_UART2,_PIN_UART2_RX, MD_PLN|MD_EZI|MD_ZI, FUNC6);

Chip_UART_Init(LPC_USART2);

Chip_UART_SetBaud(LPC_USART2,_BAUDRATE);

Chip_UART_SetupFIFOS(LPC_USART2, UART_FCR_FIFO_EN | UART_FCR_TRG_LEV0);
//El level 0 es para que cuando al fifo llegue un caracter lo mande, por ejemplo en lev3, esperaria 8 caracteres.

Chip_UART_TXEnable(LPC_USART2);
}
Esempio n. 19
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);
}
Esempio n. 20
0
/**
* @brief Maps the timer to the outputs
*
* @param[in] pin	Pointer to pin configuration
*/
void SctConfig(sctPin_t * pin){

	Chip_SCU_PinMux(sct[pin->id].port,sct[pin->id].pin, SCU_MODE_INACT, sct[pin->id].func);
	Chip_SCTPWM_SetOutPin(LPC_SCT, sct[pin->id].ch , sct[pin->id].out);
	pin->duty_cycle = 0;
	Chip_SCTPWM_SetDutyCycle(LPC_SCT,sct[pin->id].ch, Chip_SCTPWM_PercentageToTicks(LPC_SCT, 0));
}
Esempio n. 21
0
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);



}
Esempio n. 22
0
void InitUART(uint32_t BAUD)
{
/*P7_1 UART2 TXD*/
Chip_SCU_PinMux(UART2_PUERTO, UART2_PIN_TXD, MD_PDN,FUNC6);
/*P7_2 UART RXD*/
Chip_SCU_PinMux(UART2_PUERTO, UART2_PIN_RXD, MD_PLN|MD_EZI|MD_ZI,FUNC6);

Chip_UART_Init(LPC_USART2);

Chip_UART_SetBaud(LPC_USART2, BAUD);

Chip_UART_SetupFIFOS(LPC_USART2, UART_FCR_FIFO_EN|UART_FCR_TRG_LEV0);

Chip_UART_TXEnable(LPC_USART2);

}
Esempio n. 23
0
/*==================[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);

 }
/* Sets up system pin muxing */
STATIC void SystemSetupMuxing(void)
{
	int i;

	/* Setup system level pin muxing */
	for (i = 0; i < (sizeof(pinmuxing) / sizeof(pinmuxing[0])); i++) {
		Chip_SCU_PinMux(pinmuxing[i].pingrp, pinmuxing[i].pinnum,
						pinmuxing[i].pincfg, pinmuxing[i].funcnum);
	}
}
Esempio n. 25
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)
{


	   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;
}
Esempio n. 26
0
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));

}
Esempio n. 27
0
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);

}
Esempio n. 28
0
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);

}
Esempio n. 29
0
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
}
Esempio n. 30
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.
 */
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);
	 /****************************************************/

}