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(VALUE_TYPE, _MAX_SIZE)\
42 static VALUE_TYPE input_buffer[_MAX_SIZE]; \
43 static VALUE_TYPE* input_write_ptr = &input_buffer[0];\
44 static VALUE_TYPE* input_read_ptr = &input_buffer[0];\
45 static int MaxSize = _MAX_SIZE; \
46 LOCAL void IsrWriteBuffer(VALUE_TYPE value) \
48 VALUE_TYPE *save_ptr = input_write_ptr; \
49 *input_write_ptr++ = value; \
50 if (input_write_ptr > &input_buffer[MaxSize-1]) \
51 input_write_ptr = &input_buffer[0]; \
52 if (input_write_ptr == input_read_ptr) \
53 input_write_ptr = save_ptr; \
55 LOCAL BOOLEAN threadReadBuffer(VALUE_TYPE* value) \
57 if (input_read_ptr != input_write_ptr) \
59 *value = *input_read_ptr++; \
60 if (input_read_ptr > &input_buffer[MaxSize-1]) \
61 input_read_ptr = &input_buffer[0]; \
67 /**----------------------------------------------------------------------------*
68 ** Local Function Prototype **
69 **----------------------------------------------------------------------------*/
73 CHIPDRV_HISR_START_ID = 0x50,
87 hisr_func_t *hisr_func;
89 CHIPDRV_HISR_PRI_E pri;
91 struct Hisr_T* volatile next_hisr;
92 volatile uint32 hisr_count;
95 /**----------------------------------------------------------------------------*
96 ** Function Prototype **
97 **----------------------------------------------------------------------------*/
99 /*****************************************************************************/
100 // Description : This function is used to create HISR
101 // Global resource dependence :
102 // Author : steve.zhan
104 /*****************************************************************************/
105 PUBLIC void CHIPDRVHISR_Create (const uint8 *HisrName, CHIPDRV_HISR_ID_E ThreadId, void (*entry) (uint32, void *),
106 CHIPDRV_HISR_PRI_E Priority, int queueNum);
109 /*****************************************************************************/
110 // Description : This function is used in task to get semaphore.
111 // Global resource dependence :
112 // Author : steve.zhan
114 /*****************************************************************************/
115 PUBLIC uint32 CHIPDRVHISR_WaitActive (CHIPDRV_HISR_ID_E ThreadId);
118 /*****************************************************************************/
119 // Description : This function is used to activate the HISR to process some
121 // Global resource dependence :
122 // Author : steve.zhan
124 /*****************************************************************************/
125 PUBLIC void CHIPDRVHISR_Activate (CHIPDRV_HISR_ID_E ThreadId);
129 /*****************************************************************************/
130 // Description : This function Init Hisr data struct.
131 // Global resource dependence :
132 // Author : steve.zhan
134 /*****************************************************************************/
135 PUBLIC void Hisr_init(void);
138 /*****************************************************************************/
139 // Description : Invoked by ISR.
140 // Global resource dependence :
141 // Author : steve.zhan
143 /*****************************************************************************/
144 PUBLIC void Hisr_put(int Intpri);
148 /*****************************************************************************/
149 // Description : Invokedy by interrupt module, register Hisr callback
150 // function and the priority to HISR.
151 // Global resource dependence :
152 // Author : steve.zhan
154 /*****************************************************************************/
155 PUBLIC uint32 Hisr_RegHandler (
157 hisr_func_t *pHisrFunc,
158 CHIPDRV_HISR_PRI_E hisrPri,
162 /**----------------------------------------------------------------------------*
164 **----------------------------------------------------------------------------*/
168 /**---------------------------------------------------------------------------*/