00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00038 #ifndef __ALL_GENERIC_H
00039 #define __ALL_GENERIC_H
00040
00041
00042 #ifdef __linux
00043
00044 #include "pc_generic.h"
00045 #define HELLO_MSG "\n" __FILE__ ", built on " __DATE__ " at " __TIME__ "\n"
00046 #else
00047
00048 #include "pic24_generic.h"
00049 #endif
00050
00051
00059 typedef union _UINT8 {
00061 uint8 _uint8;
00063 uint8 u8;
00064 struct {
00066 unsigned b0:
00067 1;
00069 unsigned b1:
00070 1;
00072 unsigned b2:
00073 1;
00075 unsigned b3:
00076 1;
00078 unsigned b4:
00079 1;
00081 unsigned b5:
00082 1;
00084 unsigned b6:
00085 1;
00087 unsigned b7:
00088 1;
00089 };
00090 } UINT8;
00091
00109 typedef union _UINT16 {
00111 uint16 _uint16;
00113 uint16 u16;
00114 struct {
00116 uint8 u8Lsb;
00118 uint8 u8Msb;
00119 };
00120 struct {
00122 uint8 u8Bytes[2];
00123 };
00124 struct {
00126 unsigned b0:
00127 1;
00129 unsigned b1:
00130 1;
00132 unsigned b2:
00133 1;
00135 unsigned b3:
00136 1;
00138 unsigned b4:
00139 1;
00141 unsigned b5:
00142 1;
00144 unsigned b6:
00145 1;
00147 unsigned b7:
00148 1;
00150 unsigned b8:
00151 1;
00153 unsigned b9:
00154 1;
00156 unsigned b10:
00157 1;
00159 unsigned b11:
00160 1;
00162 unsigned b12:
00163 1;
00165 unsigned b13:
00166 1;
00168 unsigned b14:
00169 1;
00171 unsigned b15:
00172 1;
00173 };
00174 } UINT16;
00175
00182 #define LSB(a) ((a).u8Bytes[0])
00183
00189 #define MSB(a) ((a).u8Bytes[1])
00190
00213 typedef union _UINT32 {
00215 uint32 _uint32;
00217 uint32 u32;
00218 struct {
00220 uint8 u8LoLsb;
00222 uint8 u8LoMsb;
00224 uint8 u8HiLsb;
00226 uint8 u8HiMsb;
00227 };
00228 struct {
00230 uint16 u16LoWord;
00232 uint16 u16HiWord;
00233 };
00234 struct {
00236 uint16 u16Words[2];
00237 };
00238 struct {
00240 uint8 u8Bytes[4];
00241 };
00242 struct {
00243 unsigned b0:
00244 1;
00246 unsigned b1:
00247 1;
00249 unsigned b2:
00250 1;
00252 unsigned b3:
00253 1;
00255 unsigned b4:
00256 1;
00258 unsigned b5:
00259 1;
00261 unsigned b6:
00262 1;
00264 unsigned b7:
00265 1;
00267 unsigned b8:
00268 1;
00270 unsigned b9:
00271 1;
00273 unsigned b10:
00274 1;
00276 unsigned b11:
00277 1;
00279 unsigned b12:
00280 1;
00282 unsigned b13:
00283 1;
00285 unsigned b14:
00286 1;
00288 unsigned b15:
00289 1;
00291 unsigned b16:
00292 1;
00294 unsigned b17:
00295 1;
00297 unsigned b18:
00298 1;
00300 unsigned b19:
00301 1;
00303 unsigned b20:
00304 1;
00306 unsigned b21:
00307 1;
00309 unsigned b22:
00310 1;
00312 unsigned b23:
00313 1;
00315 unsigned b24:
00316 1;
00318 unsigned b25:
00319 1;
00321 unsigned b26:
00322 1;
00324 unsigned b27:
00325 1;
00327 unsigned b28:
00328 1;
00330 unsigned b29:
00331 1;
00333 unsigned b30:
00334 1;
00336 unsigned b31:
00337 1;
00338 };
00339 } UINT32;
00340
00341
00348 #define LOWER_WORD(a) ((a).u16Words[0])
00349
00355 #define UPPER_WORD(a) ((a).u16Words[1])
00356
00362 #define LOWER_LSB(a) ((a).u8Bytes[0])
00363
00369 #define LOWER_MSB(a) ((a).u8Bytes[1])
00370
00376 #define UPPER_LSB(a) ((a).u8Bytes[2])
00377
00383 #define UPPER_MSB(a) ((a).u8Bytes[3])
00384
00389 typedef enum _BOOL {
00391 FALSE = 0,
00393 TRUE
00394 } BOOL;
00395
00397 #define OK TRUE
00398
00399 #define FAIL FALSE
00400
00401 #define NULLPTR 0
00402
00403 #define NULLIDX 0xFF
00404
00405 #define BIT0 0x01
00406
00407 #define BIT1 0x02
00408
00409 #define BIT2 0x04
00410
00411 #define BIT3 0x08
00412
00413 #define BIT4 0x10
00414
00415 #define BIT5 0x20
00416
00417 #define BIT6 0x40
00418
00419 #define BIT7 0x80
00420
00421 #define BIT8 0x0100
00422
00423 #define BIT9 0x0200
00424
00425 #define BIT10 0x0400
00426
00427 #define BIT11 0x0800
00428
00429 #define BIT12 0x1000
00430
00431 #define BIT13 0x2000
00432
00433 #define BIT14 0x4000
00434
00435 #define BIT15 0x8000
00436
00443 #define BIT_SET_MASK(var, mask) ((var) |= (mask))
00444
00450 #define BIT_CLEAR_MASK(var, mask) ((var) &= (~(mask)))
00451
00457 #define BIT_TOGGLE_MASK(var, mask) ((var) ^= (mask))
00458
00467 #define IS_BIT_SET_MASK(var, mask) (((var) & (mask)))
00468
00477 #define IS_BIT_CLEAR_MASK(var, mask) ((~(var) & (mask)))
00478
00485 #define BIT_SET(var, bitnum) ((var) |= (1 << (bitnum)))
00486
00492 #define BIT_CLEAR(var, bitnum) ((var) &= (~(1 << (bitnum))))
00493
00499 #define BIT_TOGGLE(var, bitnum) ((var) ^= (1 << (bitnum)))
00500
00508 #define IS_BIT_SET(var, bitnum) ((var) & (1 << (bitnum)))
00509
00517 #define IS_BIT_CLEAR(var, bitnum) (~(var) & ((1 << (bitnum))))
00518
00519 #endif //ALL_GENERIC_H