Example #1
0
/*****************************************************************************
**   Main Function  main()
******************************************************************************/
int main (void)
{
  SystemInit();

  GPIOInit();

  /* use port0_1 as input event, interrupt test. */
  GPIOSetDir( PORT0, 1, 0 );
  /* port0_1, single trigger, active high. */
  GPIOSetInterrupt( PORT0, 1, 0, 0, 0 );
  GPIOIntEnable( PORT0, 1 );

  /* use port1_1 as input event, interrupt test. */
  GPIOSetDir( PORT1, 1, 0 );
  /* port0_1, single edge trigger, active high. */
  GPIOSetInterrupt( PORT1, 1, 0, 0, 0 );
  GPIOIntEnable( PORT1, 1 );

  /* use port2_1 as input event, interrupt test. */
  GPIOSetDir( PORT2, 1, 0 );
  /* port0_1, single edge trigger, active high. */
  GPIOSetInterrupt( PORT2, 1, 0, 0, 0 );
  GPIOIntEnable( PORT2, 1 );

  /* use port3_1 as input event, interrupt test. */
  GPIOSetDir( PORT3, 1, 0 );
  /* port0_1, single edge trigger, active high. */
  GPIOSetInterrupt( PORT3, 1, 0, 0, 0 );
  GPIOIntEnable( PORT3, 1 );

  while( 1 );
}
Example #2
0
/**
 * *brief	init trig pin as input, install interrupt handler on event 1
 * IO pins on lpc11xx can be configured for hysteresis ~0.4V, we enable this to avoid
 * multiple interrupts when optocoupler input is fired from a potential noisy and slow input
 * */
void trigInputInit(void)
{
    /* init timers */
    /* avoid triggerning after reset, and allow inputs to settle */
    timeLast1 = 0;
    timeLast2 = 0;
    timeEdge1 = 0;
    timeEdge2 = 0;

    /* allow interrupts on GPIO 1 & 2 */
    NVIC_EnableIRQ(EINT1_IRQn);
    NVIC_EnableIRQ(EINT2_IRQn);

    /* hard coded pins set pullups and hysteresis TODO*/
    LPC_IOCON->PIO2_2  = 0x00000030;
    LPC_IOCON->PIO1_10 = 0x000000B0;


    GPIOSetDir( TRIG_IN_PORT_1, TRIG_IN_PIN_1, 0);
    GPIOSetDir( TRIG_IN_PORT_2, TRIG_IN_PIN_2, 0);

    /* attach pin to falling edge Interrupt */
    GPIOSetInterrupt(TRIG_IN_PORT_1, TRIG_IN_PIN_1, 0, 0, 0);
    GPIOSetInterrupt(TRIG_IN_PORT_2, TRIG_IN_PIN_2, 0, 0, 0);
    /*enable interrupts*/
    GPIOIntEnable( TRIG_IN_PORT_1, TRIG_IN_PIN_1);
    GPIOIntEnable( TRIG_IN_PORT_2, TRIG_IN_PIN_2);
}
Example #3
0
// interrupter in PIO
void init_eint(void)
{
//P0.7
  GPIO_SetIOCONFunc(PORT0, 7);	
  /* 使用Port0.7作为外部中断输入测试 */
  GPIOSetDir( PORT0, 7, 0 );
  /* P0.7外部中断单端触发、高电平有效 */
  GPIOSetInterrupt( PORT0, 1, 7, 0, 0 );
  GPIOIntEnable( PORT0, 7 );
}
Example #4
0
void touchInit(){
  SSP0_IOConfig(); 
  GPIOSetDir(ADS7843_CS_GPIO,ADS7843_CS_GPIOBIT,1);  //out
  GPIOSetDir(ADS7843_INT_GPIO,ADS7843_INT_GPIOBIT,0); //in put
  GPIOSetInterrupt(ADS7843_INT_GPIO,ADS7843_INT_GPIOBIT, 0, 0, 0); //signal fall edge 
  //GPIOIntEnable(ADS7843_INT_GPIO, ADS7843_INT_GPIOBIT);
  GPIOSetValue(ADS7843_CS_GPIO,ADS7843_CS_GPIOBIT,1); //output hight
  SSP0_Init();   //spi_clk is 1mhz
  touchTimerInit();
  
}
Example #5
0
/*****************************************************************************
** Function name:		SetRemoteWakeupSource
**
** Descriptions:		Set Remote Wakeup Source
**
** parameters:			None
** Returned value:		None
** 
*****************************************************************************/
void SetRemoteWakeupSource (void)
{
 /* Enable AHB clock to the GPIO domain. */
  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);

  /* Enable AHB clock to the FlexInt, GroupedInt domain. */
  LPC_SYSCON->SYSAHBCLKCTRL |= ((1<<19) | (1<<23) | (1<<24));

  /* Route p0.1 to FLEX0 */
  LPC_SYSCON->PINTSEL[0] = 1;	/* P0.1  */

  /* use port0_1 as input event, interrupt test. */
  GPIOSetDir( PORT0, 1, 0 );
  /* INT0, edge trigger, falling edge. */
  GPIOSetInterrupt( 0, 0, 0 );
  GPIOIntEnable( 0, 0 );

  NVIC_EnableIRQ(FLEX_INT0_IRQn);
  return;
}
Example #6
0
/*******************************************************************************
* Function Name  : SPI752_Init
* Description    : Set channel 0 & 1 baud rate. The range is 300-230400 Baud.
*                  The crystal input frequency is 14745600Hz.
*				   The default value of prescaler after reset is divide-by-1.
*                  The format is: 8N1
* Input          : - Channel : 0 & 1.
*                  - Baud : 300-230400 Baud.
* Output         : None
* Return         : None
*******************************************************************************/
void SPI752_Init(uint8_t Channel, uint32_t Baud)
{
  uint16_t	rd;

  // Disable sleep
  SPI752_RegWrite(Channel, SPI752_LCR_RW, 0xBF);
  rd = SPI752_RegRead(Channel, SPI752_EFR_RW);
  SPI752_RegWrite(Channel, SPI752_EFR_RW, rd | 0x10);

  SPI752_RegWrite(Channel, SPI752_LCR_RW, 0x03);
  rd = SPI752_RegRead(Channel, SPI752_IER_RW);
  SPI752_RegWrite(Channel, SPI752_IER_RW, rd & (~0x10));

  rd = SPI752_RegRead(Channel, SPI752_MCR_RW);
  SPI752_RegWrite(Channel, SPI752_MCR_RW, rd & (~0x80));

  // Set baud rate & 8N1 format
  SPI752_RegWrite(Channel, SPI752_LCR_RW, 0x83);
  rd = (14745600/16) / Baud;
  SPI752_RegWrite(Channel, SPI752_DLL_RW, rd);
  SPI752_RegWrite(Channel, SPI752_DLH_RW, rd>>8);
  SPI752_RegWrite(Channel, SPI752_LCR_RW, 0x03);


  SPI752_RegRead(Channel, SPI752_RHR_R);

  // use port3_3 as input event, ZigBee interrupt.
  GPIOSetDir(PORT3, 3, 0);
  // port3_3 interrupt. edge, single trigger, falling edges.
  GPIOSetInterrupt(PORT3, 3, 0, 0, 0);
  GPIOIntEnable(PORT3, 3);

  // Set SPI752 RXDx interrupt Enable.
  //rd = SPI752_RegRead(1, SPI752_IER_RW);  
  //SPI752_RegWrite(Channel, SPI752_IER_RW, rd | 0x01);
  SPI752_RegWrite(Channel, SPI752_IER_RW, 0x01);

  SPI752_RegRead(Channel, SPI752_RHR_R);
}
Example #7
0
/*****************************************************************************
** Function name:		SetVBUSInterrupt
**
** Descriptions:		Set VBUS debounce as interrupt
**
** parameters:			None
** Returned value:		None
** 
*****************************************************************************/
void SetVBUSInterrupt (void)
{
  /* Enable AHB clock to the GPIO domain. */
  if ( !(LPC_SYSCON->SYSAHBCLKCTRL & (1<<6)) )
  {
	LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
  }

  /* Enable AHB clock to the FlexInt, GroupedInt domain. */
  LPC_SYSCON->SYSAHBCLKCTRL |= ((1<<19) | (1<<23) | (1<<24));

  /* Route p0.3(VBUS) to FLEX0 */
  LPC_SYSCON->PINTSEL[0] = 3;	/* P0.3  */

  /* use port0_3 as input event, interrupt test. */
  GPIOSetDir( PORT0, 3, 0 );
  /* INT0, edge trigger, falling edge. */
  GPIOSetInterrupt( 0, 0, 0 );
  GPIOIntEnable( 0, 0 );

  NVIC_EnableIRQ(FLEX_INT0_IRQn);
  return;
}
Example #8
0
void FlowrateInit()
{
    uint32_t i;

    /* Initialize GPIO (sets up clock) */
    GPIOInit();
    /* Set flow-rate port pins to input */
    GPIOSetDir(FLOWRATE_PORT, FLOWRATE_1_BIT, 0);
    GPIOSetDir(FLOWRATE_PORT, FLOWRATE_2_BIT, 0);
    GPIOSetDir(FLOWRATE_PORT, FLOWRATE_3_BIT, 0);
    GPIOSetDir(FLOWRATE_PORT, FLOWRATE_4_BIT, 0);
    GPIOSetDir(FLOWRATE_PORT, FLOWRATE_5_BIT, 0);
    GPIOSetDir(FLOWRATE_PORT, FLOWRATE_6_BIT, 0);
    GPIOSetDir(FLOWRATE_PORT, FLOWRATE_7_BIT, 0);
    GPIOSetDir(FLOWRATE_PORT, FLOWRATE_8_BIT, 0);

    //enable interrupt on both edge of the flow-rate pins
    GPIOSetInterrupt(FLOWRATE_PORT, FLOWRATE_1_BIT, 0, 1, 0);
    GPIOIntClear(FLOWRATE_PORT, FLOWRATE_1_BIT);
    GPIOIntEnable(FLOWRATE_PORT, FLOWRATE_1_BIT);

    GPIOSetInterrupt(FLOWRATE_PORT, FLOWRATE_2_BIT, 0, 1, 0);
    GPIOIntClear(FLOWRATE_PORT, FLOWRATE_2_BIT);
    GPIOIntEnable(FLOWRATE_PORT, FLOWRATE_2_BIT);

    GPIOSetInterrupt(FLOWRATE_PORT, FLOWRATE_3_BIT, 0, 1, 0);
    GPIOIntClear(FLOWRATE_PORT, FLOWRATE_3_BIT);
    GPIOIntEnable(FLOWRATE_PORT, FLOWRATE_3_BIT);

    GPIOSetInterrupt(FLOWRATE_PORT, FLOWRATE_4_BIT, 0, 1, 0);
    GPIOIntClear(FLOWRATE_PORT, FLOWRATE_4_BIT);
    GPIOIntEnable(FLOWRATE_PORT, FLOWRATE_4_BIT);

    GPIOSetInterrupt(FLOWRATE_PORT, FLOWRATE_5_BIT, 0, 1, 0);
    GPIOIntClear(FLOWRATE_PORT, FLOWRATE_5_BIT);
    GPIOIntEnable(FLOWRATE_PORT, FLOWRATE_5_BIT);

    GPIOSetInterrupt(FLOWRATE_PORT, FLOWRATE_6_BIT, 0, 1, 0);
    GPIOIntClear(FLOWRATE_PORT, FLOWRATE_6_BIT);
    GPIOIntEnable(FLOWRATE_PORT, FLOWRATE_6_BIT);

    GPIOSetInterrupt(FLOWRATE_PORT, FLOWRATE_7_BIT, 0, 1, 0);
    GPIOIntClear(FLOWRATE_PORT, FLOWRATE_7_BIT);
    GPIOIntEnable(FLOWRATE_PORT, FLOWRATE_7_BIT);

    GPIOSetInterrupt(FLOWRATE_PORT, FLOWRATE_8_BIT, 0, 1, 0);
    GPIOIntClear(FLOWRATE_PORT, FLOWRATE_8_BIT);
    GPIOIntEnable(FLOWRATE_PORT, FLOWRATE_8_BIT);

    for (i = 0; i < 8; i++)
    {
        Flowrate[i] = 0;
        count[i] = 0;
    }
    //initialize time1
    init_timer32(1, SystemCoreClock - 1);
    enable_timer32(1);
    //enable interrupt for timer and pins
    NVIC_EnableIRQ(EINT2_IRQn);
    NVIC_EnableIRQ(TIMER_32_1_IRQn);
}