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

📄 csl_intc.h

📁 TI达芬奇dm644x各硬件模块测试代码
💻 H
📖 第 1 页 / 共 3 页
字号:
        if (CSL_intcInit(&context) != CSL_SOK) {
            exit;
        }
     @endverbatim
 * =============================================================================
 */
CSL_Status CSL_intcInit (
    CSL_IntcContext *   pContext 
    /**< Pointer to the user allocated Intc context */
);

/** ============================================================================
 *   @n@b CSL_intcOpen
 *
 *   @b Description
 *   @n The API would reserve an interrupt-event for use. It returns
 *      a valid handle to the event only if the event is not currently
 *      allocated. The user could release the event after use by calling
 *      CSL_intcClose(..). The CSL-object ('intcObj') that the user
 *      passes would be used to store information pertaining handle.
 *
 *   @b Arguments
 *   @verbatim
              pIntcObj     pointer to the CSL-object allocated by the user

              eventId      the event-id of the interrupt

              param        pointer to the Intc specific parameter
              
              pStatus      (optional) pointer for returning status of the
                           function call
     @endverbatim
 *
 *   <b> Return Value </b>  CSL_IntcHandle
 *   @n                     Valid INTC handle identifying the event
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n   1.    INTC object structure is populated
 *   @n   2.    The status is returned in the status variable. If status
 *              returned is
 *   @li            CSL_SOK             Valid intc handle is returned
 *   @li            CSL_ESYS_FAIL       The open command failed
 *
 *   @b Modifies
 *   @n    1. The status variable
 *   @n    2. INTC object structure
 *
 * @b Example:
 * @verbatim

        CSL_IntcObj intcObj20;

        CSL_IntcGlobalEnableState state;

        CSL_IntcContext context;
        CSL_Status intStat;
        CSL_IntcParam vectId;

        context.numEvtEntries = 0;
        context.eventhandlerRecord = NULL;
        // Init Module
        CSL_intcInit(&context);

        // NMI Enable
        CSL_intcGlobalNmiEnable();

        // Enable Global Interrupts
        intStat = CSL_intcGlobalEnable(&state);

        // Opening a handle for the Event 20 at vector id 4

        vectId = CSL_INTC_VECTID_4;
        hIntc20 = CSL_intcOpen (&intcObj20, CSL_INTC_EVENTID_20, &vectId , NULL);

        // Close handle
        CSL_IntcClose(hIntc20);
   @endverbatim
 * =============================================================================
 */

CSL_IntcHandle   CSL_intcOpen (
	/**< pointer to the CSL-object allocated by the user */
    CSL_IntcObj *       intcObj,    
    /**< the event-id of the interrupt */
    CSL_IntcEventId     eventId,    
    /**< module specific parameter */
    CSL_IntcParam *     params,     
    /**< (optional) pointer to a variable that would receive the status */
    CSL_Status *        status
);

/** =============================================================================
 *   @n@b CSL_intcClose
 *
 *   @b Description
 *   @n This intc Handle can no longer be used to access the event. The event is 
 *    de-allocated and further access to the event resources are possible only after
 *    opening the event object again.
 *
 *   @b Arguments
 *   @verbatim
            hIntc            Handle identifying the event
     @endverbatim
 *
 *   <b> Return Value </b>  CSL_Status
 *   @li                    CSL_SOK             - Close successful
 *   @li                    CSL_ESYS_FAIL       - Close failed
 *
 *   @b Example
 *   @verbatim
        CSL_IntcContext context; 
        CSL_Status intStat;
        CSL_IntcParam vectId;
        CSL_IntcObj intcObj20;
        CSL_IntcHandle hIntc20;
        CSL_IntcEventHandlerRecord recordTable[10];
        
        context.numEvtEntries = 10;
        context.eventhandlerRecord = &recordTable;
        
        // Init Module
        ...
        if (CSL_intcInit(&context) != CSL_SOK) {
           exit;
        // Opening a handle for the Event 20 at vector id 4
        
        vectId = CSL_INTC_VECTID_4;
        hIntc20 = CSL_intcOpen (&intcObj20, CSL_INTC_EVENTID_20, &vectId , NULL);
        
        // Close handle
        CSL_IntcClose(hIntc20);    
        }       
     @endverbatim
 * =============================================================================
 */
CSL_Status  CSL_intcClose (
	/**< Handle to an event; see CSL_intcOpen(..) */
    CSL_IntcHandle      hIntc   
);
/** ============================================================================
 *  @n@b CSL_intcPlugEventHandler
 *
 *  @b Description
 *  @n Associate an event-handler with an event
 *     CSL_intcPlugEventHandler(..) ties an event-handler to an event; so
 *     that the occurence of the event, would result in the event-handler
 *     being invoked.
 *
 *  @b Arguments
 *  @verbatim
        hIntc                Handle identying the interrupt-event
        
        eventHandlerRecord   Provides the details of the event-handler
    @endverbatim
 *
 *  <b> Return Value </b>
 *  @n  Returns the address of the previous handler
 *
 *  @b Example:
 *  @verbatim
        CSL_IntcObj intcObj20;
    
        CSL_IntcGlobalEnableState state;
        
        CSL_IntcContext context; 
        CSL_Status intStat;
        CSL_IntcParam vectId;
        
        context.numEvtEntries = 0;
        context.eventhandlerRecord = NULL;
        // Init Module
        CSL_intcInit(&context);
        
        // NMI Enable   
        CSL_intcGlobalNmiEnable();
        
        // Enable Global Interrupts 
        intStat = CSL_intcGlobalEnable(&state);
        
        // Opening a handle for the Event 20 at vector id 4
        
        vectId = CSL_INTC_VECTID_4;
        hIntc20 = CSL_intcOpen (&intcObj20, CSL_INTC_EVENTID_20, &vectId , NULL);
        
        EventRecord.handler = &event20Handler;
        EventRecord.arg = hIntc20;
        CSL_intcPlugEventHandler(hIntc20,&EventRecord); 
        // Close handle
        CSL_IntcClose(hIntc20);
        }
        
        void event20Handler( CSL_IntcHandle hIntc)
        {
        
        }
    @endverbatim
 * =============================================================================
 */
CSL_Status CSL_intcPlugEventHandler (
        CSL_IntcHandle                  hIntc,
        /**< Handle identifying the interrupt-event; see CSL_intcOpen(..) */
        CSL_IntcEventHandlerRecord *    eventHandlerRecord
        /**< Provides the details of the event-handler */
);

/** ============================================================================
 *  @n@b CSL_intcHookIsr
 *
 *  @b Description
 *  @n Hook up an exception handler
 *     This API hooks up the handler to the specified exception.
 *     Note: In this case, it is done by inserting a B(ranch) instruction
 *     to the handler. Because of the restriction in the instruction
 *     th handler must be within 32MB of the exception vector.
 *     Also, the function assumes that the exception vector table is
 *     located at its default ("low") address.
 *
 *  @b Arguments
 *  @verbatim
        vectId       Interrupt Vector identifier
        
        isrAddr      Pointer to the handler
    @endverbatim
 *
 *  @b Example:
 *  @verbatim
        CSL_IntcContext context; 
        CSL_Status intStat;
        CSL_IntcParam vectId;
        CSL_IntcObj intcObj20;
        CSL_IntcHandle hIntc20;
        CSL_IntcDropStatus drop;
        CSL_IntcEventHandlerRecord recordTable[10];
        CSL_IntcGlobalEnableState state;
        Uint32 intrStat;
        
        context.numEvtEntries = 10;
        context.eventhandlerRecord = &recordTable;
        
        // Init Module
        ...
        if (CSL_intcInit(&context) != CSL_SOK)
           exit;
        // Opening a handle for the Event 20 at vector id 4
        
        vectId = CSL_INTC_VECTID_4;
        hIntc20 = CSL_intcOpen (&intcObj20, CSL_INTC_EVENTID_20, &vectId , NULL);
        
        CSL_intcNmiEnable();
        // Enable Global Interrupts 
        intStat = CSL_intcGlobalEnable(&state);
        
        // Hook Isr appropriately
        CSL_intcHookIsr(CSL_INTC_VECTID_4,&isrVect4);
        ...
         }
        interrupt void isrVect4()
        {
        
        }
        @endverbatim
 * =============================================================================
 */
CSL_Status CSL_intcHookIsr (
        CSL_IntcVectId  vectId,     /**< Vector identifier   */
        void *          isrAddr     /**< Pointer to the ISR */
);

/** ============================================================================
 *   @n@b CSL_intcHwControl
 *
 *   @b Description
 *   @n Perform a control-operation. This API is used to invoke any of the
 *      supported control-operations supported by the module.
 *
 *   @b Arguments
 *   @verbatim
            hIntc           Handle identifying the event

            command         The command to this API indicates the action to be
                            taken on INTC.

            commandArg      An optional argument.
     @endverbatim
 *
 *   <b> Return Value </b>  CSL_Status
 *   @li                    CSL_SOK             - HwControl successful.
 *   @li                    CSL_ESYS_BADHANDLE  - Invalid handle
 *   @li                    CSL_ESYS_INVCMD     - Invalid command
 *
 *   <b> Pre Condition </b>
 *   @n  CSL_intcOpen() must be invoked before this call.
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n The hardware registers of INTC.
 *
 *   @b Example
 *   @verbatim
        CSL_IntcObj intcObj20;
    
        CSL_IntcGlobalEnableState state;
        
        CSL_IntcContext context; 
        CSL_Status intStat;
        CSL_IntcParam vectId;
        
        context.numEvtEntries = 0;
        context.eventhandlerRecord = NULL;
        // Init Module
        CSL_intcInit(&context);
        
        // NMI Enable   
        CSL_intcGlobalNmiEnable();
        
        // Enable Global Interrupts 
        intStat = CSL_intcGlobalEnable(&state);
        
        // Opening a handle for the Event 20 at vector id 4
        
        vectId = CSL_INTC_VECTID_4;
        hIntc20 = CSL_intcOpen (&intcObj20, CSL_INTC_EVENTID_20, &vectId , NULL);
        
        CSL_intcHwControl(hIntc20,CSL_INTC_CMD_EVTENABLE,NULL);
     @endverbatim
 * =============================================================================
 */

CSL_Status CSL_intcHwControl (
        CSL_IntcHandle          hIntc,      
        /**< Handle to an event; see CSL_intcOpen(..) */
        CSL_IntcHwControlCmd    command,    
        /**< Command identifier */
        void *                  commandArg  
        /**< Optional command parameter */
);

/** ============================================================================
 *   @n@b CSL_intcGetHwStatus
 *
 *   @b Description
 *   @n Queries the peripheral for status. The CSL_intcGetHwStatus(..) API
 *      could be used to retrieve status or configuration information from
 *      the peripheral. The user must allocate an object that would hold
 *      the retrieved information and pass a pointer to it to the function.
 *      The type of the object is specific to the query-command.
 *
 *   @b Arguments
 *   @verbatim
            hIntc           Handle identifying the event

            query           The query to this API of INTC which indicates the
                            status to be returned.

            answer          Placeholder to return the status.
     @endverbatim
 *
 *   <b> Return Value </b> CSL_Status
 *   @li                   CSL_SOK               - Status info return successful
 *   @li                   CSL_ESYS_BADHANDLE    - Invalid handle
 *   @li                   CSL_ESYS_INVQUERY     - Invalid query
 *   @li                   CSL_ESYS_NOTSUPPORTED - Action not supported
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n None
 *
 *   @b Example:
 *   @verbatim
        CSL_IntcContext context; 
        CSL_Status intStat;
        CSL_IntcParam vectId;
        CSL_IntcObj intcObj20;
        CSL_IntcHandle hIntc20;
        CSL_IntcEventHandlerRecord recordTable[10];
        CSL_IntcGlobalEnableState state;
        Uint32 intrStat;
        
        context.numEvtEntries = 10;
        context.eventhandlerRecord = &recordTable;
        
        // Init Module
        ...
        if (CSL_intcInit(&context) != CSL_SOK)
           exit;
        // Opening a handle for the Event 20 at vector id 4
        
        vectId = CSL_INTC_VECTID_4;
        hIntc20 = CSL_intcOpen (&intcObj20, CSL_INTC_EVENTID_20, &vectId , NULL);
        
        // NMI Enable   
        CSL_intcGlobalNmiEnable();
        
        // Enable Global Interrupts 
        intStat = CSL_intcGlobalEnable(&state);
        
        do {
            CSL_intcGetHwStatus(hIntc20,CSL_INTC_QUERY_PENDSTATUS,(void*)&intrStat);
        } while (!stat);
        

⌨️ 快捷键说明

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