Ejemplo n.º 1
0
static inline void pwr_clk_and_isr(tim_t tim)
{
    switch (tim) {
        case 0:
            PCONP |= (1 << 1);
            PCLKSEL0 &= ~(0x03 << 2);
            PCLKSEL0 |=  (0x01 << 2);
            install_irq(TIMER0_INT, &tim_isr_0, 1);
            break;
#if TIMER_NUMOF > 1
        case 1:
            PCONP |= (1 << 2);
            PCLKSEL0 &= ~(0x03 << 4);
            PCLKSEL0 |=  (0x01 << 4);
            install_irq(TIMER1_INT, &tim_isr_1, 1);
            break;
#endif
#if TIMER_NUMOF > 2
        case 2:
            PCONP |= (1 << 22);
            PCLKSEL1 &= ~(0x03 << 12);
            PCLKSEL1 |=  (0x01 << 12);
            install_irq(TIMER2_INT, &tim_isr_2, 1);
            break;
#endif
#if TIMER_NUMOF > 3
        case 3:
            PCONP |= (1 << 23);
            PCLKSEL1 &= ~(0x03 << 14);
            PCLKSEL1 |=  (0x01 << 14);
            install_irq(TIMER3_INT, &tim_isr_3, 1);
            break;
#endif
    }
}
Ejemplo n.º 2
0
/******************************************************************************
** Function name:		init_timer
**
** Descriptions:		Initialize timer, set timer interval, reset timer,
**						install timer interrupt handler
**
** parameters:			timer number and timer interval
** Returned value:		true or false, if the interrupt handler can't be
**						installed, return false.
** 
******************************************************************************/
DWORD init_timer ( BYTE timer_num, DWORD TimerInterval ) 
{
  if ( timer_num == 0 )
  {
	timer0_counter = 0;
	T0MR0 = TimerInterval;
	T0MCR = 3;				/* Interrupt and Reset on MR0 */
	if ( install_irq( TIMER0_INT, (void *)Timer0Handler, HIGHEST_PRIORITY ) == FALSE )
	{
	  return (FALSE);
	}  
	else
	{
	  return (TRUE);
	}
  }
  else if ( timer_num == 1 )
  {
	timer1_counter = 0;
	T1MR0 = TimerInterval;
	T1MCR = 3;				/* Interrupt and Reset on MR1 */
	if ( install_irq( TIMER1_INT, (void *)Timer1Handler, HIGHEST_PRIORITY ) == FALSE )
	{
	  return (FALSE);
	}  
	else
	{
	  return (TRUE);
	}
  }
  return (FALSE);
}
Ejemplo n.º 3
0
void init_interrupts(void)
{
  init_VIC();

  //Timer0 interrupt
  install_irq( TIMER0_INT, (void *) timer0ISR );

  //UART1 interrupt
  install_irq( UART1_INT, (void *) uart1ISR );
  U1IER = 3; //=3; enable THRE and RX interrupt

  //UART0 interrupt
  install_irq( UART0_INT, (void *) uart0ISR );
  U0IER = 3; //=3; enable THRE and RX interrupt

  //I2C0 interrupt
//  install_irq( I2C0_INT, (void *) I2C0MasterHandler );
//  I20CONSET = I2CONSET_I2EN;

  //SSP interrupt
  install_irq( SPI1_INT, (void *) SSPHandler );
  /* Set SSPINMS registers to enable interrupts */
  /* enable all interrupts, Rx overrun, Rx timeout, RX FIFO half full int,
  TX FIFO half empty int */
  SSPIMSC = SSPIMSC_TXIM | SSPIMSC_RXIM | SSPIMSC_RORIM;// | SSPIMSC_RTIM;
  /* SSP Enabled */
  SSPCR1 |= SSPCR1_SSE;
}
Ejemplo n.º 4
0
void platform_int_init()
{
  install_irq( EINT3_INT, int_handler_eint3, HIGHEST_PRIORITY + 1 );   
  install_irq( UART0_INT, int_handler_uart0, HIGHEST_PRIORITY + 2 );
  install_irq( UART1_INT, int_handler_uart1, HIGHEST_PRIORITY + 3 );
  install_irq( UART2_INT, int_handler_uart2, HIGHEST_PRIORITY + 4 );
  install_irq( UART3_INT, int_handler_uart3, HIGHEST_PRIORITY + 5 );
}
Ejemplo n.º 5
0
/*****************************************************************************
** Function name:		UARTInit
**
** Descriptions:		Initialize UART0 port, setup pin select,
**						clock, parity, stop bits, FIFO, etc.
**
** parameters:			portNum(0 or 1) and UART baudrate
** Returned value:		true or false, return false only if the
**						interrupt handler can't be installed to the
**						VIC table
**
*****************************************************************************/
DWORD UARTInit( unsigned int PortNum, unsigned long baudrate )
{
    DWORD Fdiv;

    if ( PortNum == 0 )
    {
        PINSEL0 = 0x00000050;       /* RxD0 and TxD0 */

        U0LCR = 0x83;		/* 8 bits, no Parity, 1 Stop bit */
        Fdiv = ( PCLK / 16 ) / baudrate ;	/*baud rate */
        U0DLM = Fdiv / 256;
        U0DLL = Fdiv % 256;
        U0LCR = 0x03;		/* DLAB = 0 */
        U0FCR = 0x07;		/* Enable and reset TX and RX FIFO. */

        if ( install_irq( UART0_INT, (void *)UART0Handler, HIGHEST_PRIORITY ) == FALSE )
        {
            return (FALSE);
        }

        U0IER = IER_RBR | IER_THRE | IER_RLS;	/* Enable UART0 interrupt */
        return (TRUE);
    }
    else if ( PortNum == 1 )
    {
#if EA_BOARD_LPC24XX
        PINSEL7 |= 0x0000000F;	/* P3.16 TXD1, P3.17 RXD1 */
#else							/* Default is Keil MCB2300 board */
        PINSEL0 |= 0x40000000;	/* Enable TxD1 P0.15 */
        PINSEL1 |= 0x00000001;	/* Enable RxD1 P0.16 */
#endif
        U1LCR = 0x83;		/* 8 bits, no Parity, 1 Stop bit */
        Fdiv = ( PCLK / 16 ) / baudrate ;	/*baud rate */
        U1DLM = Fdiv / 256;
        U1DLL = Fdiv % 256;
        U1LCR = 0x03;		/* DLAB = 0 */
        U1FCR = 0x07;		/* Enable and reset TX and RX FIFO. */

        if ( install_irq( UART1_INT, (void *)UART1Handler, HIGHEST_PRIORITY ) == FALSE )
        {
            return (FALSE);
        }

        U1IER = IER_RBR | IER_THRE | IER_RLS;	/* Enable UART0 interrupt */
        return (TRUE);
    }
    return( FALSE );
}
Ejemplo n.º 6
0
/*****************************************************************************
** Function name:		UART1Init
**
** Descriptions:		Initialize UART0 port, setup pin select,
**				clock, parity, stop bits, FIFO, etc.
**
** parameters:			UART baudrate
** Returned value:		true or false, return false only if the 
**				interrupt handler can't be installed to the 
**				VIC table
** 
*****************************************************************************/
uint64 UART1Init( uint64 baudrate )
{
    uint64 Fdiv;

    PINSEL0 |= 0x00050000;       		/* Enable RxD1 and TxD1, RxD0 and TxD0 	*/

    U1LCR = 0x83;               		/* 8 bits, no Parity, 1 Stop bit    	*/
    Fdiv =( Fpclk / 16 ) / baudrate ;	/*baud rate 							*/
    U1DLM = Fdiv / 256;							
    U1DLL = Fdiv % 256;	
    U1LCR = 0x03;               		/* DLAB = 0                         	*/
    U1FCR = 0x07;						/* Enable and reset TX and RX FIFO. 	*/

    if( install_irq( UART1_INT,(void *)UART1Handler ) == FALSE )
    {
		return(FALSE);
    }

    //Initialize Index & Count
    Uart1BufferIndex = 0;
	Uart1Count = 0;
   
    U1IER = IER_RBR | IER_THRE | IER_RLS;	/* Enable UART0 interrupt */
    return(TRUE);
}
Ejemplo n.º 7
0
uint32_t SSP0Init(void)
{

    /*
     * enable clock to SSP0 for security reason.
     * By default, it's enabled already
     */
    PCONP |= PCSSP0;
    //TODO: configure CLK, MISO, MOSI by default as  GPIOs.
#if USE_CS
    //  P1.20 1.21 1.23 1.24
    //  PINSEL3 |= BIT8 | BIT9 | BIT10 | BIT11 | BIT14 | BIT15 | BIT16 | BIT17;
#else
    //  No SSEL0
    //  PINSEL3 |= BIT8 | BIT9 | BIT14 | BIT15 | BIT16 | BIT17; //1.20 1.23 1.24
#endif

#if SSP1_INTERRUPT_MODE

    if (install_irq(SSP1_INT, (void *)SSP0Handler, HIGHEST_PRIORITY) == FALSE) {
        return (FALSE);
    }

    /*
     * Set SSPINMS registers to enable interrupts,
     * enable all error related interrupts
     */

    SSP1IMSC = SSPIMSC_RORIM | SSPIMSC_RTIM;
#endif

    return (1);
}
Ejemplo n.º 8
0
Archivo: rtc.c Proyecto: A-Paul/RIOT
void rtc_poweron(void)
{
    PCONP |= BIT9;
    RTC_ILR = (ILR_RTSSF | ILR_RTCCIF | ILR_RTCALF);    /* clear interrupt flags */
    RTC_CCR |= CCR_CLKEN;                               /* enable clock */
    install_irq(RTC_INT, &RTC_IRQHandler, IRQP_RTC);    /* install interrupt handler */
}
Ejemplo n.º 9
0
Archivo: uart.c Proyecto: daniel-k/RIOT
int uart_init(uart_t dev, uint32_t baudrate,
              uart_rx_cb_t rx_cb, uart_tx_cb_t tx_cb, void *arg)
{
    /* for now, we only support one UART device and only the RX interrupt */
    if (dev != 0) {
        return -1;
    }

    /* save interrupt context */
    _rx_cb = rx_cb;
    _tx_cb = tx_cb;
    _cb_arg = arg;

    /* power on the UART device */
    PCONP |= PCUART0;
    /* UART0 clock divider is CCLK/8 */
    PCLKSEL0 |= BIT6 + BIT7;
    /* configure to 8N1 */
    U0LCR = 0x83;

    /* Baudrate calculation:
     * BR = PCLK (9 MHz) / (16 x 256 x DLM + DLL) x (1/(DIVADDVAL/MULVAL)) */
    /* TODO: UART Baudrate calculation using the baudrate parameter */
    U0FDR = 0x92;       /* DIVADDVAL = 0010 = 2, MULVAL = 1001 = 9 */
    U0DLM = 0x00;
    U0DLL = 0x04;

    U0LCR = 0x03;       /* DLAB = 0 */
    U0FCR = 0x07;       /* Enable and reset TX and RX FIFO */

    /* install and enable the IRQ handler */
    install_irq(UART0_INT, UART0_IRQHandler, 6);
    U0IER |= BIT0;       /* enable only RX irq */
    return 0;
}
Ejemplo n.º 10
0
/*****************************************************************************
 ** Function name:		UARTInit
 **
 ** Descriptions:		Initialize UART3 port, setup pin select,
 **				clock, parity, stop bits, FIFO, etc.
 **
 ** parameters:			UART baudrate
 ** Returned value:		true or false, return false only if the
 **				interrupt handler can't be installed to the
 **				VIC table
 **
 *****************************************************************************/
DWORD UART3Init( DWORD baudrate )
//DWORD UARTInit(  )

{
	DWORD Fdiv;
	PCONP |= 1<<25;
	PINSEL1 &= ~0xF<<18;       /* Enable RxD3 and Not TxD1,  */
	PINSEL1 |= 0xC<<18;

	//LCR value determines format of data character that is to be transmitted or received
	/* 8 bits, no Parity, 1 Stop bit    */
	//DLAB = 1, enable access to DLL and DLM registers
	U3LCR = 0x83;
	Fdiv = ( Fpclk / 16 ) / baudrate ;	/*baud rate */
	//    U3DLM = Fdiv / 256;
	//    U3DLL = Fdiv % 256;
	U3DLL = 0x4C;
	U3DLM = 0x0;
	U3FDR = 0x21;
	U3LCR = 0x03;       /*DLAB = 0 */
	U3FCR = 0x47;		/* Enable and reset TX and RX FIFO. */
	U3FCR = 0x40;
	if ( install_irq( UART3_INT, (void *)UART3Handler, HIGHEST_PRIORITY+1 ) == FALSE )
	{
		return (FALSE);
	}

	keypadValue = 0; // set keypadValue to "unpressed"

	U3IER = IER_RBR | IER_THRE | IER_RLS;	/* Enable UART3 interrupt */
	return (TRUE);
}
Ejemplo n.º 11
0
// Helper function: setup timers
static void platform_setup_timers()
{
  unsigned i;
  PREG TxTCR;

  // Set base frequency to 1MHz, as we can't use a better resolution anyway
  for( i = 0; i < 4; i ++ )
  {
    TxTCR = ( PREG )tmr_tcr[ i ];
    *TxTCR = 0;
    platform_timer_set_clock( i, 1000000ULL );
  }
#if VTMR_NUM_TIMERS > 0
  // Setup virtual timers here
  // Timer 3 is allocated for virtual timers and nothing else in this case
  T3TCR = TMR_RESET;
  T3MR0 = 1000000ULL / VTMR_FREQ_HZ - 1;
  T3IR = 0xFF;
  // Set interrupt handle and eanble timer interrupt (and global interrupts)
  T3MCR = 0x03; // interrupt on match with MR0 and clear on match
  install_irq( TIMER3_INT, int_handler_tmr, HIGHEST_PRIORITY ); 
  platform_cpu_set_global_interrupts( PLATFORM_CPU_ENABLE );
  // Start timer
  T3TCR = TMR_ENABLE;
#endif
}
Ejemplo n.º 12
0
int
bl_uart_init(void)
{
    PCONP |= PCUART0;                               // power on

    // UART0 clock divider is CCLK/8
    PCLKSEL0 |= BIT6 + BIT7;

    U0LCR = 0x83;                                   // 8 bits, no Parity, 1 Stop bit

    // TODO: UART Baudrate calculation using uart->config->speed
    /*
     * Baudrate calculation
     * BR = PCLK (9 MHz) / (16 x 256 x DLM + DLL) x (1/(DIVADDVAL/MULVAL))
     */
    U0FDR = 0x92;       // DIVADDVAL = 0010 = 2, MULVAL = 1001 = 9
    U0DLM = 0x00;
    U0DLL = 0x04;

    U0LCR = 0x03;       // DLAB = 0
    U0FCR = 0x07;       // Enable and reset TX and RX FIFO

    /* irq */
    install_irq(UART0_INT, UART0_IRQHandler, 6);
    U0IER |= BIT0;       // enable only RX irq
    return 1;
}
Ejemplo n.º 13
0
/*****************************************************************************
** Function name:		I2CInit
**
** Descriptions:		Initialize I2C controller
**
** parameters:			I2c mode is either MASTER or SLAVE
** Returned value:		true or false, return false if the I2C
**				interrupt handler was not installed correctly
** 
*****************************************************************************/
DWORD I2CInit( DWORD I2cMode ) //0 slave 1 master
{
  PCONP |= (1 << 19);
 // PINSEL1 &= ~0x03C00000;
 // PINSEL1 |=  0x01400000;	/* set PIO0.27 and PIO0.28 to I2C1 SDA and SCK */
  PINSEL0 |= 0x0000000F;  /* function to 01 on both SDA and SCK. for I21 */

  PINMODE0 &=~0x0000000F;
  PCLKSEL1 &=~0x000000C0;
  PCLKSEL1 |= 0x000000C0;
  /*--- Clear flags ---*/
  I21CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC;

  /*--- Reset registers ---*/
  I21SCLL   = I2SCLL_SCLL;
  I21SCLH   = I2SCLH_SCLH;
  if ( I2cMode == I2CSLAVE )
  {
	I21ADR = LCD_ADDR;
  }    

  /* Install interrupt handler */	
  if ( install_irq( I2C1_INT, (void *)I2C1MasterHandler, HIGHEST_PRIORITY +6) == FALSE )
  {
	  printLED(0xAA);
	 // busyWait(100);
	return( FALSE );
  }
  IENABLE;
  I21CONSET = I2CONSET_I2EN;
  return( TRUE );
}
Ejemplo n.º 14
0
Archivo: rtc.c Proyecto: A-Paul/RIOT
void rtc_poweroff(void)
{
    RTC_CCR &= ~CCR_CLKEN;  /* disable clock */
    install_irq(RTC_INT, NULL, 0);
    RTC_ILR = 0;
    PCONP &= ~BIT9;
}
Ejemplo n.º 15
0
/******************************************************************************
** Function name:		init_timer
**
** Descriptions:		Initialize timer, set timer interval, reset timer,
**						install timer interrupt handler
**
** parameters:			timer number and timer interval
** Returned value:		__TRUE or __FALSE, if the interrupt handler can't be
**						installed, return __FALSE.
** 
******************************************************************************/
DWORD init_timer ( U8 timer_num, DWORD TimerInterval ) 
{
  if ( timer_num == 0 )
  {
	timer0_counter = 0;
	//T0MR0 = TimerInterval;
	T0MR0 = TimerInterval * (14400000 / 1000-1);
	T0MCR = 3;				/* Interrupt and Reset on MR0 */
#if FIQ
	/* FIQ is always installed. */
	VICIntSelect |= (0x1<<4);
	VICIntEnable = (0x1<<4);
	return (__TRUE);
#else
	if ( install_irq( TIMER0_INT, (void *)Timer0Handler, 5 ) == __FALSE )
	{
	  return (__FALSE);
	}  
	else
	{
	  return (__TRUE);
	}
#endif
  }
  else if ( timer_num == 1 )
  {
	timer1_counter = 0;
	T1MR0 = TimerInterval;
	T1MCR = 3;				/* Interrupt and Reset on MR1 */
#if FIQ
	VICIntSelect |= (0x1<<5);
	VICIntEnable = (0x1<<5);
	return (__TRUE);
#else
	if ( install_irq( TIMER1_INT, (void *)Timer1Handler, 5 ) == __FALSE )
	{
	  return (__FALSE);
	}  
	else
	{
	  return (__TRUE);
	}
#endif
  }
  return (__FALSE);
}
Ejemplo n.º 16
0
void gpioint_init(void)
{
    extern void GPIO_IRQHandler(void);

    /* GPIO Init */
    INTWAKE |= GPIO0WAKE | GPIO2WAKE;                       /* allow GPIO to wake up from power down */
    install_irq(GPIO_INT, &GPIO_IRQHandler, IRQP_GPIO);     /* install irq handler */
}
Ejemplo n.º 17
0
Archivo: gpio.c Proyecto: JMR-b/RIOT
int gpio_init_int(gpio_t pin, gpio_pp_t pullup, gpio_flank_t flank,
                    gpio_cb_t cb, void *arg)
{
    DEBUG("gpio_init_int(): pin %u\n", pin);
    int isr_map_entry;

    /* check if interrupt is possible for this pin */
    if ((isr_map_entry = _isr_map_entry(pin)) == -1) {
        DEBUG("gpio_init_int(): pin %u cannot be used to generate interrupts.\n", pin);
        return -1;
    }

    /* find free isr state entry */
    int _state_index = _gpio_isr_map[isr_map_entry];

    if (_state_index == 0xff) {
        _state_index = bf_get_unset(_gpio_config_bitfield, GPIO_NUM_ISR);
        _gpio_isr_map[isr_map_entry] = _state_index;
        DEBUG("gpio_init_int(): pin has state_index=%i isr_map_entry=%i\n", _state_index, isr_map_entry);
    }

    if (_state_index == 0xff) {
#ifdef DEVELHELP
        puts("lpc2387: gpio: warning: no free gpio callback state!");
#endif
        return -1;
    }

    /* store callback */
    _gpio_states[_state_index].cb = cb;
    _gpio_states[_state_index].arg = arg;

    extern void GPIO_IRQHandler(void);
    gpio_init(pin, GPIO_DIR_IN, pullup);

    if (flank & GPIO_FALLING) {
        bf_set(_gpio_falling, _state_index);
    }
    else {
        bf_unset(_gpio_falling, _state_index);
    }

    if (flank & GPIO_RISING) {
        bf_set(_gpio_rising, _state_index);
    }
    else {
        bf_unset(_gpio_rising, _state_index);
    }

    _gpio_configure(pin, flank & GPIO_RISING, flank & GPIO_FALLING);

    /* activate irq */
    INTWAKE |= GPIO0WAKE | GPIO2WAKE;                       /* allow GPIO to wake up from power down */
    install_irq(GPIO_INT, &GPIO_IRQHandler, IRQP_GPIO);     /* install irq handler */

    return 0;
}
Ejemplo n.º 18
0
Archivo: ssp.c Proyecto: dmtrkun/Andr
/*****************************************************************************
** Function name:		SSP0Init
**
** Descriptions:		SSP0 port initialization routine
**				
** parameters:			None
** Returned value:		true or false, if the interrupt handler
**						can't be installed correctly, return false.
** 
*****************************************************************************/
DWORD SSP0Init( void )
{
  BYTE i, Dummy=Dummy;

  /* enable clock to SSP0 for security reason. By default, it's enabled already */
  PCONP |= (1 << 21);

  /* Configure PIN connect block */
  /* bit 32, 54, 76 are 0x10, bit 98 are 0x00 */
  /* port 0 bits 17, 18, 19, 20 are SSP port SCK0, MISO0, MOSI0, and SSEL0 */
  /* set SSEL to GPIO pin that you will have the totoal freedom to set/reset 
  the SPI chip-select pin */
  /* When DMA is enabled, enable USE_CS, or be careful with SSP0_SEL pin,
  clear SSP0_SEL before DMA starts, and set SSP0_SEL after finishing. */ 
#if USE_CS
  PINSEL0 |= 0x80000000;
  PINSEL1 |= 0x0000002A;
#else
  PINSEL0 |= 0x80000000;
  PINSEL1 |= 0x00000028;
  IODIR0 = SSP0_SEL;	/* SSEL is output */
  IOSET0 = SSP0_SEL;	/* set SSEL to high */
#endif
		
  /* Set DSS data to 8-bit, Frame format SPI, CPOL = 0, CPHA = 0, and SCR is 15 */
  SSP0CR0 = 0x0707;

  /* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */
#if LOOPBACK_MODE
  SSP0CPSR = 0x2;
#else
  /* Much slower clock is needed in order to test serial EEPROM. */
  SSP0CPSR = 0x40;
#endif

  for ( i = 0; i < FIFOSIZE; i++ )
  {
	Dummy = SSP0DR;		/* clear the RxFIFO */
  }

  if ( install_irq( SPI0_INT, (void *)SSP0Handler, HIGHEST_PRIORITY ) == FALSE )
  {
	return (FALSE);
  }
	
  /* Device select as master, SSP Enabled */
#if LOOPBACK_MODE
  SSP0CR1 = SSPCR1_LBM | SSPCR1_SSE;
#else
  SSP0CR1 = SSPCR1_SSE;
#endif
  /* Set SSPINMS registers to enable interrupts */
  /* enable all error related interrupts */
  SSP0IMSC = SSPIMSC_RORIM | SSPIMSC_RTIM;
  return( TRUE );
}
Ejemplo n.º 19
0
void Comms_DTMF_Init(void)
{
	/*Set up Queue and content counter*/
	//DTMF_BUFF = xQueueCreate( DTMF_BUFF_LENGTH, ( unsigned portBASE_TYPE ) sizeof( DtmfTone ) );

	//disable EXT3 interrupt first, noting all P[2] GPIO pins share EXT3 Interrupt
	VICIntEnable &= ~BIT(17);

	//Set edge sensitive
	EXTMODE |=  DTMF_EDGE_SEN;
	//Set polarity to rising edge sensitive
	EXTPOLAR  |= DTMF_RISING_EDGE ;

	//set pin 10,15(P2[5,0]) to be GPIO
	set_Gpio_func(2,5,0);
	set_Gpio_func(2,0,0);
	//set (P2[1-4;6-9]) to be GPIO
	set_Gpio_func(2,6,0);
	set_Gpio_func(2,7,0);
	set_Gpio_func(2,8,0);
	set_Gpio_func(2,9,0);

	set_Gpio_func(2,1,0);
	set_Gpio_func(2,2,0);
	set_Gpio_func(2,3,0);
	set_Gpio_func(2,4,0);

	//set all to be input pins
	setGPIOdir(2,5,INPUT);
	setGPIOdir(2,0,INPUT);

	setGPIOdir(2,6,INPUT);
	setGPIOdir(2,7,INPUT);
	setGPIOdir(2,8,INPUT);
	setGPIOdir(2,9,INPUT);

	setGPIOdir(2,1,INPUT);
	setGPIOdir(2,2,INPUT);
	setGPIOdir(2,3,INPUT);
	setGPIOdir(2,4,INPUT);
	//enable rising edge interrupt
	IO2IntEnR |= (DTMF_INT_PINS_SIN);
	IO2IntEnF &=~ DTMF_INT_PINS_SIN;

    // TODO: Move setting up GPIO VIC to gpio driver
	EXTINT|= 0x1<<3;//clear the interupt
	VICVectAddr =0;
	IO2IntClr = DTMF_INT_PINS_SIN;//clear the GPIO interrupts
	VICIntEnable |= BIT(17);//enable VIC interrupt for EXT3
	install_irq(17, GPIO_Handler, HIGHEST_PRIORITY );
	enable_VIC_irq(17);
	led_init();
	led(0);
}
Ejemplo n.º 20
0
Archivo: rtc.c Proyecto: RharryR/KiteOS
// Initiates the IRQ and tells it to interrupt
void 
rtc_init()
{
	install_irq(8, rtc_interrupt);
	
	__asm__ __volatile__ ("cli");
	
	outb(0x70, 0x8B);
	char foo = inb(0x71);
	outb(0x70, 0x8B);
	outb(0x71, foo | 0x40);
	
	__asm__ __volatile__ ("sti");
} 
Ejemplo n.º 21
0
/******************************************************************************
** Function name:		init_timer
**
** Descriptions:		Initialize timer, set timer interval, reset timer,
**						install timer interrupt handler
**
** parameters:			None
** Returned value:		true or false, if the interrupt handler can't be
**						installed, return false.
** 
******************************************************************************/
int init_timer ( int TimerInterval ) 
{
    timer_counter = 0;
    T0MR0 = TimerInterval;
    T0MCR = 3;				/* Interrupt and Reset on MR0*/ 
    if ( install_irq( 4, (void *)Timer0Handler, 0x01 ) == FALSE )
    {
		return (FALSE);
    }
   else
    {
		return (TRUE);
    }
}
Ejemplo n.º 22
0
/******************************************************************************
** Function name:		init_timer
**
** Descriptions:		Initialize timer, set timer interval, reset timer,
**				install timer interrupt handler
**
** parameters:			None
** Returned value:		true or false, if the interrupt handler can't be
**				installed, return false.
** 
******************************************************************************/
DWORD init_timer (void) 
{
    timer_counter = 0;
    T0MR0 = INTERVAL_5S;	/* 50 * 10mSec = 50 * (150.000-1) counts */
    T0MCR = 3;			/* Interrupt and Reset on MR0 */
    if ( install_irq( TIMER0_INT, (void *)Timer0Handler ) == FALSE )
    {
	return (FALSE);
    }
    else
    {
	return (TRUE);
    }
}
Ejemplo n.º 23
0
static void initialisation(void){
	PCONP |= (1 << 12); 					// Enable power to AD block
	for (i = 0; i < 20000000; i++); 		// Wait for initial display
	IODIR0 |= 0x00000C00; 					// config touch LED pins as outputs
	led_green(); 							// make the LED green

	PINMODE4 &= ~(0xFFFF); 					// P2[7:0]pullups
	PINSEL4 &= ~(0xFFFF); 					// P2[7:0]are GPIO
	FIO2DIR0 = 0xFF; 						// P2[7:0]are outputs
	FIO2MASK0 = 0x00; 						// P2[7:0]enabled for fast I/O

	touch_detect();							// setup for touch detection
	install_irq(17, (void*)detected, 1); 	// setup interrupt vector
	IO0_INT_EN_F = X_plus;					// enable falling edge X-plus interrupt
}
Ejemplo n.º 24
0
// **************************************************************************
// Function name:		init_uart
//
// Descriptions:		Initialize UART0 port, setup pin select,
//						clock, parity, stop bits, FIFO, etc.
//
// parameters:			portNum(0 or 1) and UART baudrate
// Returned value:		true or false, return false only if the 
//						interrupt handler can't be installed to the 
//						VIC table
// 
// **************************************************************************
UINT32 init_uart( UINT32 PortNum, UINT32 baudrate )
{
    UINT32 Fdiv;

	if ( PortNum == 0 )
	{
		PINSEL0 |= PINSEL0_P0_2_TXD0 | PINSEL0_P0_3_RXD0;	// P0.2-TxD0,P0.3-RxD0

    	U0LCR = 0x83;		// 8 bits, no Parity, 1 Stop bit 
    	Fdiv = ( Fpclk / 16 ) / baudrate ;	// baud rate 
    	U0DLM = Fdiv / 256;							
    	U0DLL = Fdiv % 256;
		U0LCR = 0x03;		// DLAB = 0 
    	U0FCR = 0x07;		// Enable and reset TX and RX FIFO. 

    	/*
    	if ( install_irq( UART0_INT, (void *)IRQ_Uart0, HIGHEST_PRIORITY ) == FALSE )
    	{
			return (FALSE);
    	}
   
    	U0IER = IER_RBR | IER_THRE | IER_RLS;	// Enable UART0 interrupt
    	*/ 
    	return (TRUE);
	}
	else if ( PortNum == 1 )
	{
					
		PINSEL0 |= PINSEL0_P0_15_TXD1;	// Enable TxD1 P0.15 
		PINSEL1 |= PINSEL1_P0_16_RXD1;	// Enable RxD1 P0.16 
    	U1LCR = 0x83;		// 8 bits, no Parity, 1 Stop bit 
    	Fdiv = ( Fpclk / 16 ) / baudrate ;	// baud rate 
    	U1DLM = Fdiv / 256;							
    	U1DLL = Fdiv % 256;
		U1LCR = 0x03;		// DLAB = 0 */
    	U1FCR = 0x07;		// Enable and reset TX and RX FIFO. 

    	if ( install_irq( UART1_INT, (void *)IRQ_Uart1, HIGHEST_PRIORITY ) == FALSE )
    	{
			return (FALSE);
    	}
   
    	//U1IER = IER_RBR | IER_THRE | IER_RLS;	// Enable UART1 interrupt 
    	U1IER = IER_RBR | IER_RLS;	// Enable UART1 interrupt
    	return (TRUE);
	}
	return( FALSE ); 
}
Ejemplo n.º 25
0
void kernel_main()
{
	terminal_initialize();
	kprintf("Identifying CPU...", COLOR_WHITE);
	cpuid_t cpu_data = get_cpuid();
	kprintf(cpu_data.make, COLOR_WHITE);
	kprintf("\n", COLOR_WHITE);
	kprintf("Type: ", COLOR_WHITE);
	kprintf(itoa(cpu_data.family), COLOR_WHITE);
	kprintf("\n", COLOR_WHITE);
	kprintf("Family: ", COLOR_WHITE);
	kprintf(cpu_data.family, COLOR_WHITE);
	kprintf("\n", COLOR_WHITE);
	kprintf("Model: ", COLOR_WHITE);
	kprintf(cpu_data.model, COLOR_WHITE);
	kprintf("\n", COLOR_WHITE);
	kprintf("Enabling A20 Line...\n", COLOR_WHITE);
	enable_a20();
	kprintf("Initilizing VGA Driver....\n",COLOR_WHITE);
	kprintf("Installing Global Descriptor Table....\n",COLOR_WHITE);
	gdt_install();
	kprintf("Installing Interrupt Descriptor Table....\n",COLOR_WHITE);
	idt_install();
	kprintf("Enabling paging...\n", COLOR_WHITE);
	init_paging();
	kprintf("Setting up ISRs...\n",COLOR_WHITE);
	isrs_install();
	kprintf("Remapping the PIC and setting up IRQs...\n",COLOR_WHITE);
	install_irq();
	kprintf("Initializing the Kernel Address Translation Table...\n", COLOR_WHITE);
	kATT_Init();
	kprintf("Identifying ATA drives.....\n", COLOR_WHITE);
	ATA_Init();
	kprintf(DRIVE_DATA, COLOR_WHITE);
        kprintf("Installing Timer ISR....\n",COLOR_WHITE);
 	timer_install();
//	kprintf("Checking PCI device vendors....\n",COLOR_WHITE);
//	init_PCI();
	kprintf("Starting shell....\n",COLOR_WHITE);

	init_shell();

	for (;;);
}
Ejemplo n.º 26
0
Archivo: i2c.c Proyecto: JMR-b/RIOT
bool i2c_irq_handler_register(uint8_t i2c_interface, void *handler)
{
    bool successful = false;

    switch (i2c_interface) {
        case I2C0:
            if (handler == NULL) {
                successful = install_irq(I2C0_INT,
                                         (void *) i2c_interface0_master_handler,
                                         HIGHEST_PRIORITY);
            }
            else {
                successful = install_irq(I2C0_INT, (void *) handler,
                                         HIGHEST_PRIORITY);
            }

            break;

        case I2C1_0:
        case I2C1_1:
            if (handler == NULL) {
                successful = install_irq(I2C1_INT,
                                         (void *) i2c_interface1_master_handler,
                                         HIGHEST_PRIORITY);
            }
            else {
                successful = install_irq(I2C1_INT, (void *) handler,
                                         HIGHEST_PRIORITY);
            }

            break;

        case I2C2:
            if (handler == NULL) {
                successful = install_irq(I2C2_INT,
                                         (void *) i2c_interface2_master_handler,
                                         HIGHEST_PRIORITY);
            }
            else {
                successful = install_irq(I2C2_INT, (void *) handler,
                                         HIGHEST_PRIORITY);
            }
    }

    return successful;
}
Ejemplo n.º 27
0
void install_keyboard(void){
	install_irq(IRQ_BASE + 1, Keyboard_event);
	return;
}