예제 #1
0
/*
** ===================================================================
**     Method      :  MQX1_PEX_RTOS_InstallInterrupt (component MQXLite)
**
**     Description :
**         Installs the interrupt service routine through the RTOS.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void PEX_RTOS_InstallInterrupt(IRQInterruptIndex IntVector, void (*IsrFunction)(void *), void *IsrParam)
{
  if (IntVector >= 15) {
    /* Interrupts are install through the MQX standard ISR installation mechanism */
    (void)_int_install_isr(IntVector, (INT_ISR_FPTR)IsrFunction, IsrParam);
  } else {
    /* Interrupts are install through the MQX kernel ISR installation mechanism */
    (void)_int_install_kernel_isr(IntVector, (INT_KERNEL_ISR_FPTR)IsrFunction);
  }
}
예제 #2
0
/****************************************************************
*
* Function Name : init_interrupt_btn
* Comments      :
*   Open the pin BSP_BTN1 for input, initialize interrupt and set
*   interrupt handler.
*
*****************************************************************/
void init_interrupt_btn(void * button)
{

    LWGPIO_STRUCT_PTR btn_ptr = (LWGPIO_STRUCT_PTR) button;
    /* opening pins for input */
    if (!lwgpio_init(btn_ptr, BSP_BUTTON1, LWGPIO_DIR_INPUT, LWGPIO_VALUE_NOCHANGE))
    {
        printf("Initializing button GPIO as input failed.\n");
        _task_block();
    }
#ifdef BSP_BUTTON1_MUX_IRQ
    lwgpio_set_functionality(btn_ptr, BSP_BUTTON1_MUX_IRQ);
#if defined(BSP_BUTTONS_ACTIVE_HIGH)
    lwgpio_set_attribute(btn_ptr, LWGPIO_ATTR_PULL_DOWN, LWGPIO_AVAL_ENABLE);
#else
    lwgpio_set_attribute(btn_ptr, LWGPIO_ATTR_PULL_UP, LWGPIO_AVAL_ENABLE);
#endif
    /* enable gpio functionality for given pin, react on falling edge */
    if (! lwgpio_int_init(btn_ptr, LWGPIO_INT_MODE_FALLING))
    {
        printf("Initializing button GPIO for interrupt failed.\n");
        _task_block();
    }

    /* Install the interrupt directly to the vector table in the processor. */
    if(! _int_install_kernel_isr(lwgpio_int_get_vector(btn_ptr), btn_kernel_isr))
    {
        printf("Install interrupt handler to hardware vector table failed.\n");
        _task_block();
    }

    /* set the interrupt level, and unmask the interrupt in interrupt controller */
    if(MQX_OK != _bsp_int_init(lwgpio_int_get_vector(btn_ptr), 3, 0, TRUE))
    {
        printf("Initialize interrupt failed.\n");
        _task_block();
    }

    /* enable interrupt on GPIO peripheral module */
    lwgpio_int_enable(btn_ptr, TRUE);
#else
    printf("This platform does not support pin mux interrupt function\n");
    _task_block();
#endif /* BSP_BUTTON1_MUX_IRQ */
}