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

📄 sma_priority_driver.h

📁 在sharp 404开发板的串口测试代码
💻 H
字号:
/**********************************************************************
 *	$Workfile:   SMA_priority_driver.h  $
 *	$Revision:   1.1  $
 *	$Author:   lij  $
 *	$Date:   Mar 28 2002 14:18:22  $
 *
 *	Project: LH79520 EVB
 *
 *	Description:
 *   This module contains functions for parsing status bits with
 *   constant latency and software assignable priorities. See
 *   priority_driver.c for a complete description.
 *
 *	Revision History:
 *	$Log:   P:/PVCS6_6/archives/Priority/SMA_priority_driver.h-arc  $
 * 
 *    Rev 1.1   Mar 28 2002 14:18:22   lij
 * Add SHARP Legal Header
 * 
 *    Rev 1.0   Jan 31 2002 10:49:00   SuryanG
 * Initial revision.
 * 
 *    Rev 1.3   Jan 31 2002 10:10:52   KovitzP
 * Added default handler argument so that inadvertant source
 * triggers after a source handler is removed will not cause a
 * problem.
 * 
 *    Rev 1.2   Jan 03 2002 16:09:44   KovitzP
 * Removed the const property of the PRIORITY_DATA type fields
 * 
 *    Rev 1.1   Jan 03 2002 08:50:14   KovitzP
 * Removed the highest_priority parameter from 
 * MAKE_DISPATCHER() macro in priority_driver.h;
 * Changes rippled through.
 * 
 *    Rev 1.0   Dec 28 2001 13:26:02   KovitzP
 * Initial revision.
 *
 * SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION
 * OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE,
 * AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES, 
 * SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE.
 *
 * SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY 
 * FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A 
 * SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT. USE OF THIS SOURCE
 * FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS.
 *
 *	COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
 *		CAMAS, WA
 *********************************************************************/
#if !defined PRIORITY_DRIVER_H
#define PRIORITY_DRIVER_H

#include "SMA_types.h"

/**********************************************************************
*
* Macros: PRIORITY_MAKE_DISPATCHER
*
* Purpose:
*  Generate a dispatcher function that uses the priority encoder scheme
*  Use PRIORITY_MAKE_DISPATCHER8 for up to 8 status bits.
*  Use PRIORITY_MAKE_DISPATCHER16 for up to 16 status bits.
*  Use PRIORITY_MAKE_DISPATCHER24 for up to 24 status bits.
*  Use PRIORITY_MAKE_DISPATCHER32 for up to 32 status bits.
*
* Processing:
*  See priority_driver.c for a detailed description
*
* Parameters:
*   status_read_expression: the method used to read status. This can
*                           be a simple expression or a function call
*   handler_array:          The name of the handler list decalred as:
*                           void (*handler_list[])(void);
*   priority_encode_base_name: priority encode arrays have the form
*                              encode0, encode1, encode2, encode3
* Outputs:
*   global highest_priority is set to the highest priority
*
* Returns: Nothing
*
* Notes:
*
**********************************************************************/

#define MAKE_DISPATCHER8( \
                        status_read_expression, \
                        handler_array, \
                        priority_encode_base_name) \
{ \
 UNS_32 status; \
 INT_8 highest_priority; \
   \
 status = (status_read_expression); \
 highest_priority = priority_encode_base_name ## [status]; \
 handler_array[highest_priority]();\
}

#define MAKE_DISPATCHER16( \
                        status_read_expression, \
                        handler_array, \
                        priority_encode_base_name) \
{ \
 UNS_32 status; \
 INT_8 priority; \
 INT_8 priority0; \
 INT_8 priority1; \
 \
 status = (status_read_expression); \
 priority0 = priority_encode_base_name ## 0[status & _BITMASK(8)]; \
 priority1 = priority_encode_base_name ## 1[(status >> 8) & _BITMASK(8)]; \
 \
 if (priority0 < priority1) \
    priority = priority0; \
 else \
    priority = priority1; \
 \
 handler_array[priority]();\
}

#define MAKE_DISPATCHER24( \
                        status_read_expression, \
                        handler_array, \
                        priority_encode_base_name) \
{ \
 UNS_32 status; \
 INT_8 priority; \
 INT_8 priority0; \
 INT_8 priority1; \
 INT_8 priority2; \
 INT_8 priority3; \
 \
 status = (status_read_expression); \
 priority0 = priority_encode_base_name ## 0[status & _BITMASK(8)]; \
 priority1 = priority_encode_base_name ## 1[(status >> 8) & _BITMASK(8)]; \
 priority2 = priority_encode_base_name ## 2[(status >> 16)& _BITMASK(8)]; \
 \
 if (priority0 < priority1) \
    priority3 = priority0; \
 else \
    priority3 = priority1; \
 if (priority3 < priority2) \
    priority = priority3; \
 else \
    priority = priority2; \
 \
 handler_array[priority]();\
}

#define MAKE_DISPATCHER32( \
                        status_read_expression, \
                        handler_array, \
                        priority_encode_base_name) \
{ \
 UNS_32 status; \
 INT_8 priority; \
 INT_8 priority0; \
 INT_8 priority1; \
 INT_8 priority2; \
 INT_8 priority3; \
 INT_8 priority4; \
 INT_8 priority5; \
 \
 status = (status_read_expression); \
 priority0 = priority_encode_base_name ## 0[status & _BITMASK(8)]; \
 priority1 = priority_encode_base_name ## 1[(status >> 8) & _BITMASK(8)]; \
 priority2 = priority_encode_base_name ## 2[(status >> 16)& _BITMASK(8)]; \
 priority3 = priority_encode_base_name ## 3[(status >> 24)& _BITMASK(8)]; \
 \
 if (priority0 < priority1) \
    priority4 = priority0; \
 else \
    priority4 = priority1; \
 if (priority2 < priority3) \
    priority5 = priority2; \
 else \
    priority5 = priority3; \
 if (priority4 < priority5) \
    priority = priority4; \
 else \
    priority = priority5; \
 \
 handler_array[priority]();\
}

/*
The PRIORITY_DATA structure type contains all the information
required to support the dispatcher macros above.
*/
typedef struct
{
   /* nsources is the number of priority-encoded sources */
   INT_32 nsources;
   /* 
   priorities[i] is the priority number of the ith source. If
   the ith source has no handler function, priorities[i] == nsources.
   */
   INT_8 * priorities;
   /* 
   priority_encode0..priority_encode3 contain the priority encoder
   tables for up to a 32-bit status register. If nsources <= 24, 
   priority_encode3 == NULL. If there nsources <= 16, 
   priority_encode2 == NULL. If there nsources <= 8, 
   priority_encode1 == NULL. See priority_driver.c and the 
   MAKE_DISPATCHER macros above for a description of how the 
   priority_encode arrays are used
   */
   INT_8 * priority_encode0;
   INT_8 * priority_encode1;
   INT_8 * priority_encode2;
   INT_8 * priority_encode3;
   /* 
   handlers[i] is a pointer to the handler function for the source
   with the ith priority.
   */
   void (* * handlers)(void);
} PRIORITY_DATA;

/* functions */
void priority_init_driver(PRIORITY_DATA * const prio,
                          void (*fp)(void));
INT_8 priority_install_handler(PRIORITY_DATA * const prio,
                              INT_8 source, 
                              INT_8 priority, 
                              void (*hp)(void),
                              void (*dhp)(void));

INT_8 priority_remove_handler(PRIORITY_DATA * const prio,
                             INT_8 priority,
                             void (*hp)(void));

INT_8 priority_get_priority(PRIORITY_DATA * const prio,
                            INT_8 source);

void (*priority_get_handler(PRIORITY_DATA * const prio,
                                   INT_8 source))(void);

INT_8 priority_get_source(PRIORITY_DATA * const prio,
                          INT_8 priority);

INT_8 priority_next_available(PRIORITY_DATA * const prio,
                              INT_8 min_prio,
                              INT_8 max_prio,
                              void (*hp)(void));

#endif

⌨️ 快捷键说明

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