summaryrefslogtreecommitdiff
path: root/software/octdeviceapi/oct6100api/oct6100_miscellaneous_priv.h
blob: c0381f46b225f73416f47a906d0c58a37f9efc32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\

File:  oct6100_miscellaneous_priv.h

    Copyright (c) 2001-2007 Octasic Inc.
    
Description: 

	File containing all private defines, macros, structures and prototypes 
	pertaining to the file oct6100_miscellaneous.c.  All elements defined in 
	this file are for private usage of the API.

This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
free software; you can redistribute it and/or modify it under the terms of 
the GNU General Public License as published by the Free Software Foundation; 
either version 2 of the License, or (at your option) any later version.

The OCT6100 GPL API is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
for more details. 

You should have received a copy of the GNU General Public License 
along with the OCT6100 GPL API; if not, write to the Free Software 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.

$Octasic_Release: OCT612xAPI-01.00-PR49 $

$Octasic_Revision: 20 $

\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/

#ifndef __OCT6100_MISCELLANEOUS_PRIV_H__
#define __OCT6100_MISCELLANEOUS_PRIV_H__

/*****************************  INCLUDE FILES  *******************************/


/*****************************  DEFINES  *************************************/


/*---------------------------------------------------------------------------*\
	Macros used to shell the user function calls.  These macros are used to
	assert that the user does not change any of the members of the function's
	parameter structure, as required and indicated in the API specification.
	Ofcourse, these macros make the code heavier and thus slower.  That is why
	there is a compile option for disabling the extra checking.  These can be
	very helpful tools in debugging.
\*---------------------------------------------------------------------------*/

#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK
#define mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )					\
{																			\
	PVOID	_pProcessContext;												\
	UINT32	_ulUserChipId;													\
	UINT32	_ulWriteAddress;												\
	UINT16	_usWriteData;													\
																			\
	/* Store the data that is to be passed to the user. */					\
	_pProcessContext = WriteParams.pProcessContext;							\
	_ulUserChipId = WriteParams.ulUserChipId;								\
	_ulWriteAddress = WriteParams.ulWriteAddress;							\
	_usWriteData = WriteParams.usWriteData;									\
																			\
	/* Call user function. */												\
	ulResult = Oct6100UserDriverWriteApi( &WriteParams );					\
																			\
	/* Check if user changed members of function's parameter structure. */	\
	if ( WriteParams.pProcessContext != _pProcessContext ||					\
		 WriteParams.ulUserChipId != _ulUserChipId ||						\
		 WriteParams.ulWriteAddress != _ulWriteAddress ||					\
		 WriteParams.ulWriteAddress != _ulWriteAddress ||					\
		 WriteParams.usWriteData != _usWriteData )							\
		ulResult = cOCT6100_ERR_FATAL_DRIVER_WRITE_API;						\
}
#else																		
#define mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )					\
	ulResult = Oct6100UserDriverWriteApi( &WriteParams );
#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */


#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK
#define mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult )				\
{																				\
	PVOID	_pProcessContext;													\
	UINT32	_ulUserChipId;														\
	UINT32	_ulWriteAddress;													\
	UINT16	_usWriteData;														\
	UINT32	_ulWriteLength;														\
																				\
	/* Store the data that is to be passed to the user. */						\
	_pProcessContext = SmearParams.pProcessContext;								\
	_ulUserChipId = SmearParams.ulUserChipId;									\
	_ulWriteAddress = SmearParams.ulWriteAddress;								\
	_usWriteData = SmearParams.usWriteData;										\
	_ulWriteLength = SmearParams.ulWriteLength;									\
																				\
	/* Call user function. */													\
	ulResult = Oct6100UserDriverWriteSmearApi( &SmearParams );					\
																				\
	/* Check if user changed members of function's paraeter structure. */		\
	if ( SmearParams.pProcessContext != _pProcessContext ||						\
		 SmearParams.ulUserChipId != _ulUserChipId ||							\
		 SmearParams.usWriteData != _usWriteData ||								\
		 SmearParams.ulWriteLength != _ulWriteLength)							\
		ulResult = cOCT6100_ERR_FATAL_DRIVER_WRITE_SMEAR_API;					\
}
#else																		
#define mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult )				\
	ulResult = Oct6100UserDriverWriteSmearApi( &SmearParams );
#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */


#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK
#define mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult )			\
{																			\
	PVOID	_pProcessContext;												\
	UINT32	_ulUserChipId;													\
	UINT32	_ulWriteAddress;												\
	PUINT16	_pusWriteData;													\
	UINT32	_ulWriteLength;													\
																			\
	/* Store the data that is to be passed to the user. */					\
	_pProcessContext = BurstParams.pProcessContext;							\
	_ulUserChipId = BurstParams.ulUserChipId;								\
	_ulWriteAddress = BurstParams.ulWriteAddress;							\
	_pusWriteData = BurstParams.pusWriteData;								\
	_ulWriteLength = BurstParams.ulWriteLength;								\
																			\
	/* Call user function. */												\
	ulResult = Oct6100UserDriverWriteBurstApi( &BurstParams );				\
																			\
	/* Check if user changed members of function's parameter structure. */	\
	if ( BurstParams.pProcessContext != _pProcessContext ||					\
		 BurstParams.ulUserChipId != _ulUserChipId ||						\
		 BurstParams.ulWriteAddress != _ulWriteAddress ||					\
		 BurstParams.pusWriteData != _pusWriteData ||						\
		 BurstParams.ulWriteLength != _ulWriteLength )						\
		ulResult = cOCT6100_ERR_FATAL_DRIVER_WRITE_BURST_API;				\
}
#else																		
#define mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult )			\
	ulResult = Oct6100UserDriverWriteBurstApi( &BurstParams );
#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */


#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK
#define mOCT6100_DRIVER_READ_API( ReadParams, ulResult )					\
{																			\
	PVOID	_pProcessContext;												\
	UINT32	_ulUserChipId;													\
	UINT32	_ulReadAddress;													\
	PUINT16	_pusReadData;													\
																			\
	/* Store the data that is to be passed to the user. */					\
	_pProcessContext = ReadParams.pProcessContext;							\
	_ulUserChipId = ReadParams.ulUserChipId;								\
	_ulReadAddress = ReadParams.ulReadAddress;								\
	_pusReadData = ReadParams.pusReadData;									\
																			\
	/* Call user function. */												\
	ulResult = Oct6100UserDriverReadApi( &ReadParams );						\
																			\
	/* Check if user changed members of function's parameter structure. */	\
	if ( ReadParams.pProcessContext != _pProcessContext ||					\
		 ReadParams.ulUserChipId != _ulUserChipId ||						\
		 ReadParams.ulReadAddress != _ulReadAddress ||						\
		 ReadParams.pusReadData != _pusReadData )							\
		ulResult = cOCT6100_ERR_FATAL_DRIVER_READ_API;						\
}
#else																		
#define mOCT6100_DRIVER_READ_API( ReadParams, ulResult )					\
	ulResult = Oct6100UserDriverReadApi( &ReadParams );
#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */


#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK
#define mOCT6100_DRIVER_READ_BURST_API( BurstParams, ulResult )				\
{																			\
	PVOID	_pProcessContext;												\
	UINT32	_ulUserChipId;													\
	UINT32	_ulReadAddress;													\
	PUINT16	_pusReadData;													\
	UINT32	_ulReadLength;													\
																			\
	/* Store the data that is to be passed to the user. */					\
	_pProcessContext = BurstParams.pProcessContext;							\
	_ulUserChipId = BurstParams.ulUserChipId;								\
	_ulReadAddress = BurstParams.ulReadAddress;								\
	_pusReadData = BurstParams.pusReadData;									\
	_ulReadLength = BurstParams.ulReadLength;								\
																			\
	/* Call user function. */												\
	ulResult = Oct6100UserDriverReadBurstApi( &BurstParams );				\
																			\
	/* Check if user changed members of function's parameter structure. */	\
	if ( BurstParams.pProcessContext != _pProcessContext ||					\
		 BurstParams.ulUserChipId != _ulUserChipId ||						\
		 BurstParams.ulReadAddress != _ulReadAddress ||						\
		 BurstParams.pusReadData != _pusReadData ||							\
		 BurstParams.ulReadLength != _ulReadLength )						\
		ulResult = cOCT6100_ERR_FATAL_DRIVER_READ_BURST_API;				\
}
#else																		
#define mOCT6100_DRIVER_READ_BURST_API( BurstParams, ulResult )				\
	ulResult = Oct6100UserDriverReadBurstApi( &BurstParams );
#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */

#define mOCT6100_ASSIGN_USER_READ_WRITE_OBJ( f_pApiInst, Params )

#define mOCT6100_CREATE_FEATURE_MASK( f_ulFieldSize, f_ulFieldBitOffset, f_pulFieldMask )					\
{																											\
	(*f_pulFieldMask) = ( 1 << f_ulFieldSize );																\
	(*f_pulFieldMask) --;																					\
	(*f_pulFieldMask) <<= f_ulFieldBitOffset;																\
}


/*****************************  TYPES  ***************************************/


/************************** FUNCTION PROTOTYPES  *****************************/

UINT32 Oct6100ApiWaitForTime(
				IN OUT	tPOCT6100_INSTANCE_API		f_pApiInstance,
				IN		UINT32						f_aulWaitTime[ 2 ] );

UINT32 Oct6100ApiWaitForPcRegisterBit(
				IN OUT	tPOCT6100_INSTANCE_API		f_pApiInstance,
				IN		UINT32						f_ulPcRegAdd,
				IN		UINT32						f_ulPcBitNum,
				IN		UINT32						f_ulValue,
				IN		UINT32						f_ulTimeoutUs,
				OUT		PBOOL						f_pfBitEqual );

UINT32 Oct6100ApiWriteDword( 
				IN OUT	tPOCT6100_INSTANCE_API		f_pApiInstance,
				IN		UINT32						f_ulAddress,
				IN		UINT32						f_ulWriteData );

UINT32 Oct6100ApiReadDword( 
				IN OUT	tPOCT6100_INSTANCE_API		f_pApiInstance,
				IN		UINT32						f_ulAddress,
				OUT		PUINT32						f_pulReadData );

VOID Oct6100ApiCreateFeatureMask( 
				IN		UINT32						f_ulFieldSize,
				IN		UINT32						f_ulFieldBitOffset,
				OUT		PUINT32						f_pulFieldMask );

unsigned char const *Oct6100ApiStrStr( 
				IN		unsigned char const				*f_pszSource, 
				IN		unsigned char const				*f_pszString, 
				IN		unsigned char const				*f_pszLastCharPtr );

UINT32 Oct6100ApiStrLen( 
				IN		unsigned char const				*f_pszString );

UINT32 Oct6100ApiAsciiToHex( 
				IN		UINT8						f_chCharacter, 
				IN		PUINT32						f_pulValue );

UINT8 Oct6100ApiHexToAscii( 
				IN		UINT32						f_ulNumber );

UINT32 Oct6100ApiRand( 
				IN		UINT32						f_ulRange );

UINT32 oct6100_retrieve_nlp_conf_dword(tPOCT6100_INSTANCE_API f_pApiInst,
								tPOCT6100_API_CHANNEL f_pChanEntry,
								UINT32 f_ulAddress,
								UINT32 *f_pulConfigDword);

UINT32 oct6100_save_nlp_conf_dword(tPOCT6100_INSTANCE_API f_pApiInst,
								tPOCT6100_API_CHANNEL f_pChanEntry,
								UINT32 f_ulAddress,
								UINT32 f_ulConfigDword);

#endif /* __OCT6100_MISCELLANEOUS_PRIV_H__ */