Netcruzer Library API  V2.03
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
nz_helpers.h
Go to the documentation of this file.
1 
46 #ifndef NZ_HELPERS_H
47 #define NZ_HELPERS_H
48 
49 #if defined(HAS_WEBSERVER)
50 //Function prototypes for functions defined in Helpers.h
51 BYTE btohexa_high(BYTE b);
52 BYTE btohexa_low(BYTE b);
53 #endif
54 
55 
56 #define delay_us(us) nzDelayUs(us)
57 #define delay_ms(ms) nzDelayMs(ms)
58 
59 
66 void nzDelayMs(WORD msDelay);
67 
68 
75 void nzDelayUs(WORD usDelay);
76 
77 
78 #define DWORD_BYTE0(dw) ((unsigned char)((dw)&0xFF))
79 #define DWORD_BYTE1(dw) ((unsigned char)(((dw)>>8)&0xFF))
80 #define DWORD_BYTE2(dw) ((unsigned char)(((dw)>>16)&0xFF))
81 #define DWORD_BYTE3(dw) ((unsigned char)(((dw)>>24)&0xFF))
82 
90 #define nzDwordGetLowByte_MACRO(dw) ((unsigned char)((dw)&0xFF))
91 #define DWORD_LOW_BYTE(dw) ((unsigned char)((dw)&0xFF))
92 
100 #define nzDwordGetHighByte_MACRO(dw) ((unsigned char)(((dw)>>24)&0xFF))
101 #define DWORD_HIGH_BYTE(dw) ((unsigned char)(((dw)>>24)&0xFF))
102 
103 
111 #define nzDwordGetLowWord_MACRO(dw) ((unsigned char)((dw)&0xFFFF))
112 #define DWORD_LOW_WORD(dw) ((unsigned char)((dw)&0xFFFF))
113 
114 
122 #define nzDwordGetHighWord_MACRO(dw) ((unsigned char)(((dw)>>16)&0xFFFF))
123 #define DWORD_HIGH_WORD(dw) ((unsigned char)(((dw)>>16)&0xFFFF))
124 
125 #define WORD_BYTE0(w) ((unsigned char)((w)&0xFF))
126 #define WORD_BYTE1(w) ((unsigned char)(((w)>>8)&0xFF))
127 
135 #define nzWordGetLowByte_MACRO(w) ((unsigned char)((w)&0xFF))
136 #define WORD_LOW_BYTE(w) ((unsigned char)((w)&0xFF))
137 
138 
144 #define nzWordGetHighByte_MACRO(w) ((unsigned char)(((w)>>8)&0xFF))
145 #define WORD_HIGH_BYTE(w) ((unsigned char)(((w)>>8)&0xFF))
146 
147 
155 #define nzByteGetLowNibble_MACRO(b) ((unsigned char)((b)&0x0F))
156 #define BYTE_LOW_NIBBLE(b) ((unsigned char)((b)&0x0F))
157 
158 
166 #define nzByteGetHighNibble_MACRO(b) ((unsigned char)(((b)>>4)&0x0F))
167 #define BYTE_HIGH_NIBBLE(b) ((unsigned char)(((b)>>4)&0x0F))
168 
169 
177 #define nzWordSetHighByte_MACRO(w, b) (((BYTE*)&(w))[1] = (b))
178 
179 
187 #define nzWordSetLowByte_MACRO(w, b) (((BYTE*)&(w))[0] = (b))
188 
189 
198 #define nzWordFromBytes_MACRO(msb,lsb) ( ((WORD)((msb)<<8)) | ((WORD)(lsb)) )
199 #define WORD_FROM_BYTES(msb,lsb) ( ((WORD)((msb)<<8)) | ((WORD)(lsb)) )
200 
201 
212 BYTE nzAsciiHexToByte(WORD_VAL asciiChars);
213 #if defined(HAS_WEBSERVER)
214 #define nzAsciiHexToByte(asciiChars) hexatob(asciiChars)
215 #endif
216 
217 
227 BYTE nzAsciiHexNibbleToByte(BYTE c);
228 
229 
241 WORD_VAL nzByteToAsciiHex(BYTE b);
242 
243 
255 void nzByteToAsciiHexStr(BYTE b, char* dst);
256 
257 
266 BYTE nzLowNibbleToAsciiHex(BYTE b);
267 #if defined(HAS_WEBSERVER)
268 #define nzLowNibbleToAsciiHex(b) btohexa_low(b)
269 #endif
270 
279 BYTE nzHighNibbleToAsciiHex(BYTE b);
280 #if defined(HAS_WEBSERVER)
281 #define nzHighNibbleToAsciiHex(b) btohexa_high(b)
282 #endif
283 
289 BYTE nzBitCount(WORD x);
290 
297 BYTE nzBitCountArr(BYTE* p, BYTE size);
298 
299 
319 WORD nzParseDecHexWord(const char* str, BYTE* retFlags);
320 
321 
341 WORD nzParseHexDecWord(const char* str, BYTE* retFlags);
342 
343 
351 void nzUintToAsciiStr(WORD val, BYTE* buf);
352 
353 
376 void nzFlashWriteConst(DWORD adr, BYTE newVal);
377 
378 
387 void nzMemCpy(BYTE* pDst, BYTE* pSrc, WORD count);
388 
401 void nzMemCpyNoCheck(BYTE* pDst, BYTE* pSrc, WORD count);
402 
411 void nzMemCpyDecNoCheck(BYTE* pDst, BYTE* pSrc, WORD count);
412 
413 
414 #endif