⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lh7a400_int_driver.c

📁 sharp触摸屏测试代码
💻 C
📖 第 1 页 / 共 3 页
字号:
*
* Purpose:
*  Return the priority of the specified interrupt
*
* Processing:
*  return irq_prioirties[source] if source is in range
*  otherwise return N_IRQ_HANDLERS
*
* Parameters: 
*  source: the bit number of the interrupt 
*
* Outputs: None
*
* Returns:
*  Returns the priority of the source or N_IRQ_HANDLERS if the
*  wource is not in range
*
* Notes:
*  Argument passed must be the interrupt controller bit number.
*  as defined in LH7A400_map.h for each interrupt source.
*
**********************************************************************/
INT_8 int_irq_priority(UNS_32 source)
{
    if (source > INTC_N_SOURCES_TOTAL)
        return -1;
    else
        return priority_get_priority(&irq_data, 
                            (INT_8)(source - INTC_N_IRQ_HANDLERS));
}

/**********************************************************************
*
* Function: int_fiq_priority
*
* Purpose:
*  Return the priority of the specified interrupt
*
* Processing:
*  return fiq_prioirties[source] if source is in range
*  otherwise return N_FIQ_HANDLERS
*
* Parameters: 
*  source: the bit number of the interrupt 
*
* Outputs: None
*
* Returns:
*  Returns the priority of the source or N_FIQ_HANDLERS if the
*  wource is not in range
*
* Notes:
*  Argument passed must be the interrupt controller bit number.
*  as defined in LH7A400_map.h for each interrupt source.
*
**********************************************************************/
INT_8 int_fiq_priority(UNS_32 source)
{
    if (source > INTC_LOWEST_FIQ_PRIORITY)
        return -1;
    else
        return priority_get_priority(&fiq_data, (INT_8)source);
}

/**********************************************************************
*
* Function: int_init_fiq_handler
*
* Purpose:
*  Initialize the FIQ dispatcher and handler function arrays to a known
*  state so that handlers may be subsequently installed. Set up the
*  FIQ exception vector so that any IRQ exception will vector to
*  the LH7A400_FIQ_handler fuction.
*
* Processing:
*  Associate each source with no handler function handlers[source]=0 and
*  with illegal priority priorities[source] = ILLEGAL_PRIORITY. Make
*  all priority encode tables fiq_priority_encode[all combinations]=
*  ILLEGAL_PRIORITY.
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
*  You must call this function before installing any FIQ handlers and
*  before enabling FIQ interrupts.
*
**********************************************************************/
void int_init_fiq_handler(void)
{
	INTC->enableclear = INTC_ALL_FIQS;
   fiq_data.nsources = INTC_N_FIQ_HANDLERS;
   fiq_data.priorities = fiq_priorities;
   fiq_data.priority_encode0 = (INT_8 *)((UNS_32)&fiq_priority_encode_0
                                    - (UNS_32)&LH7A400_FIQ_dispatcher + 
                                      ARM_FIQ_VEC);
   fiq_data.priority_encode1 = 0;
   fiq_data.priority_encode2 = 0;
   fiq_data.priority_encode3 = 0;
   fiq_data.handlers = (vfpp)((UNS_32)&fiq_handlers_0 - 
                              (UNS_32)&LH7A400_FIQ_dispatcher + 
                              ARM_FIQ_VEC);
   priority_init_driver(&fiq_data, 
                        (vfp)((UNS_32)&LH7A400_unhandled_fiq_handler - 
                              (UNS_32)&LH7A400_FIQ_dispatcher 
                               + ARM_FIQ_VEC) );

   /* install LH7A400_fiq_dispatcher() at fiq exception location */   
   int_install_fiq_dispatcher();
}

/**********************************************************************
*
* Function: int_install_fiq_handler
*
* Purpose:
*  This function installs the IRQ handler for a particular interrupt
*  source. The priority of the handler can be defined, with 0 being 
*  lowest priority and 3 being the highest.
*
* Processing:
*  If the handler function is NULL, if the requested priority is out
*  of range, if the source is out of range return ILLEGAL_PRIORITY.
*  Otherwise, install the handler function in the handler array at
*  the priority index. If the old priority for the source is the same
*  as the new priority, then we are just changing the handler function.
*  Otherwise, we have to clear the handler for the source that previously
*  had this priority from the priority encoder arrays and reassign the
*  priority to the new source.
*
* Parameters:
*  souce: the bit number of the FIQ source. See LH7A400_map.h
*  priority: a number between 0 and 3. 3 is the highest priority.
*  hp: a pointer to a function that returns nothing and takes no
*      arguments.
*
* Outputs: None
*
* Returns:
*  The function returns the priority of the handler if the installation
*  is successful, otherwise it returns ILLEGAL_PRIORITY.
*
* Notes:
*  It is important that the
*  application ensures that every handler is assigned a unique priority.
*  Otherwise, the most recently installed handler will be associated 
*  with the given priority and the previous handler will be lost, 
*  and may result in the interrupt for the corresponding source not 
*  being serviced.
*
*   (*hp)() must clear the interrupt before it exits.
*
**********************************************************************/
INT_8 int_install_fiq_handler(UNS_32 source, 
                              UNS_32 priority,
                              void (*hp)(void))
{
    if ((source > INTC_LOWEST_FIQ_PRIORITY) || 
                        (priority > INTC_LOWEST_FIQ_PRIORITY))
        return -1;
    else
        return priority_install_handler(&fiq_data,
                        (INT_8)source,
                        (INT_8)priority,
                        hp,
                        (vfp)((UNS_32)&LH7A400_unhandled_fiq_handler - 
                        (UNS_32)&LH7A400_FIQ_dispatcher 
                        + ARM_FIQ_VEC));
}

/**********************************************************************
*
* Function: int_remove_fiq_handler
*
* Purpose:
*  Remove the assoication between a priority and a source
*
* Processing:
*  Use a sentinel search algorithm to determine the source from
*  the priority. Set the handler function pointer to 0. Set the 
*  source priority to ILLEGAL_PRIORITY and rebuild the priority
*  encode tables.
*
* Parameters: Priority number to remove
*
* Outputs: None
*
* Returns:
*  The priority that was removed or ILLEGAL_PRIORITY if the priority
*  was never installed
*
* Notes:
*
**********************************************************************/
INT_8 int_remove_fiq_handler(UNS_32 priority)
{
    if (priority > INTC_LOWEST_FIQ_PRIORITY)
        return -1;
    else
        return priority_remove_handler(&fiq_data,
                        (INT_8)priority,
                        (vfp)((UNS_32)&LH7A400_unhandled_fiq_handler - 
                        (UNS_32)&LH7A400_FIQ_dispatcher 
                        + ARM_FIQ_VEC) );
}

/**********************************************************************
*
* Function: int_handler
*
* Purpose:
*  Return the handler function for the specified source (IRQ or FIQ)
*
* Processing:
*   if it is an FIQ source, return the FIQ handler.
*   if it is an IRQ source, return the IRQ handler
*   otherwise, return 0
*
* Parameters: 
*  source: the bit number of the interrupt 
*
* Outputs: None
*
* Returns:
*  A pointer to the handler function or 0 if there is 
*  no handler function for the source
*
* Notes:
*  Argument passed must be the interrupt controller bit number.
*  as defined in LH7A400_map.h for each interrupt source.
*
**********************************************************************/
void (* int_handler(UNS_32 source))(void)
{
   if (source < INTC_N_FIQ_HANDLERS)
   {
      return priority_get_handler(&fiq_data, (INT_8)source);
   }
   else if (source < INTC_N_FIQ_HANDLERS + INTC_N_IRQ_HANDLERS)
   {
      return priority_get_handler(&irq_data, 
                            (INT_8)(source - INTC_N_FIQ_HANDLERS));
   }
   return 0;
}

/**********************************************************************
*
* Function: irq_next_available
*
* Purpose:
*  Return the lowest available priority number in the range specified
*
* Processing: n/a
*
* Parameters: 
*  range_start: the start number of the set of vectors to search
*  range_end: the end number of the set of vectors to search
*
* Outputs: None
*
* Returns:
*  Returns the lowest priority available or range_end 
*
* Notes:
*  range_start must be smaller than range_end
*
**********************************************************************/
INT_8 irq_next_available(UNS_32 range_start, UNS_32 range_end)
{
    if ((range_start > INTC_N_SOURCES_TOTAL) || 
                                (range_end > INTC_N_SOURCES_TOTAL))
        return -1;
    else
        return priority_next_available(&irq_data, 
                                (INT_8)range_start,
                                (INT_8)range_end,
                                LH7A400_unhandled_handler);
}
 
/**********************************************************************
*
* Function: fiq_next_available
*
* Purpose:
*  Return the lowest available priority number in the range specified
*
* Processing: n/a
*
* Parameters: 
*  range_start: the start number of the set of vectors to search
*  range_end: the end number of the set of vectors to search
*
* Outputs: None
*
* Returns:
*  Returns the lowest priority available or range_end 
*
* Notes:
*  range_start must be smaller than range_end
*
**********************************************************************/
INT_8 fiq_next_available(UNS_32 range_start, UNS_32 range_end)
{
    if ((range_start > INTC_LOWEST_FIQ_PRIORITY) || 
                        (range_end > INTC_LOWEST_FIQ_PRIORITY))
        return -1;
    else
        return priority_next_available(&fiq_data, 
                        (INT_8)range_start,
                        (INT_8)range_end,
                        (vfp)(LH7A400_unhandled_fiq_handler));
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -