1 /******************************************************************************
2 ** File Name: int_hisr.h *
3 ** Author: Steve.Zhan *
5 ** Copyright: 2010 Spreatrum, Incoporated. All Rights Reserved. *
7 ******************************************************************************/
8 /******************************************************************************
10 **---------------------------------------------------------------------------*
11 ** DATE NAME DESCRIPTION *
12 ** 06/29/2010 Steve.Zhan Create. *
13 ******************************************************************************/
14 #ifndef __INT_HISR_H__
15 #define __INT_HISR_H__
18 #include "isr_drvapi.h"
20 /*----------------------------------------------------------------------------*
22 **------------------------------------------------------------------------- */
24 /**---------------------------------------------------------------------------*
26 **--------------------------------------------------------------------------*/
32 /**---------------------------------------------------------------------------*
34 **---------------------------------------------------------------------------*/
35 /*****************************************************************************/
36 // Description: Circular Buffer Function MACROS..
37 // Is used to hold characters that arrive before the application is ready for them
39 // Note: Use these three MACROS together..
40 /*****************************************************************************/
41 #define INPUT_BUFFER_INIT(_MAX_SIZE)\
42 static int input_buffer[_MAX_SIZE]; \
43 static int* input_write_ptr = &input_buffer[0];\
44 static int* input_read_ptr = &input_buffer[0];\
45 static int MaxSize = _MAX_SIZE
47 #define ISR_WRITE_BUFFER_DEF \
48 LOCAL void IsrWriteBuffer(int value) \
50 int *save_ptr = input_write_ptr; \
51 *input_write_ptr++ = value; \
52 if (input_write_ptr > &input_buffer[MaxSize-1]) \
53 input_write_ptr = &input_buffer[0]; \
54 if (input_write_ptr == input_read_ptr) \
55 input_write_ptr = save_ptr; \
59 #define THREAD_READ_BUFFER_DEF \
60 LOCAL BOOLEAN threadReadBuffer(int* value) \
62 if (input_read_ptr != input_write_ptr) \
64 *value = *input_read_ptr++; \
65 if (input_read_ptr > &input_buffer[MaxSize-1]) \
66 input_read_ptr = &input_buffer[0]; \
72 /**----------------------------------------------------------------------------*
73 ** Local Function Prototype **
74 **----------------------------------------------------------------------------*/
78 CHIPDRV_HISR_START_ID = 0x50,
92 hisr_func_t *hisr_func;
94 CHIPDRV_HISR_PRI_E pri;
96 struct Hisr_T* volatile next_hisr;
97 volatile uint32 hisr_count;
100 /**----------------------------------------------------------------------------*
101 ** Function Prototype **
102 **----------------------------------------------------------------------------*/
104 /*****************************************************************************/
105 // Description : This function is used to create HISR
106 // Global resource dependence :
107 // Author : steve.zhan
109 /*****************************************************************************/
110 PUBLIC void CHIPDRVHISR_Create (const uint8 *HisrName, CHIPDRV_HISR_ID_E ThreadId, void (*entry) (uint32, void *),
111 CHIPDRV_HISR_PRI_E Priority, int queueNum);
114 /*****************************************************************************/
115 // Description : This function is used in task to get semaphore.
116 // Global resource dependence :
117 // Author : steve.zhan
119 /*****************************************************************************/
120 PUBLIC uint32 CHIPDRVHISR_WaitActive (CHIPDRV_HISR_ID_E ThreadId);
123 /*****************************************************************************/
124 // Description : This function is used to activate the HISR to process some
126 // Global resource dependence :
127 // Author : steve.zhan
129 /*****************************************************************************/
130 PUBLIC void CHIPDRVHISR_Activate (CHIPDRV_HISR_ID_E ThreadId);
134 /*****************************************************************************/
135 // Description : This function Init Hisr data struct.
136 // Global resource dependence :
137 // Author : steve.zhan
139 /*****************************************************************************/
140 PUBLIC void Hisr_init(void);
143 /*****************************************************************************/
144 // Description : Invoked by ISR.
145 // Global resource dependence :
146 // Author : steve.zhan
148 /*****************************************************************************/
149 PUBLIC void Hisr_put(int Intpri);
153 /*****************************************************************************/
154 // Description : Invokedy by interrupt module, register Hisr callback
155 // function and the priority to HISR.
156 // Global resource dependence :
157 // Author : steve.zhan
159 /*****************************************************************************/
160 PUBLIC uint32 Hisr_RegHandler (
162 hisr_func_t *pHisrFunc,
163 CHIPDRV_HISR_PRI_E hisrPri,
167 /**----------------------------------------------------------------------------*
169 **----------------------------------------------------------------------------*/
173 /**---------------------------------------------------------------------------*/