macro.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef _MACRO_H
  2. #define _MACRO_H
  3. #define UINT_MAX 0xffffffff
  4. #define BIT(n) (1ul << (n))
  5. #define STR(x) #x
  6. #define AT(x) __attribute__((section(STR(x))))
  7. #define ALIGNED(n) __attribute__((aligned(n)))
  8. #define DMA_ADR(x) ((u32)x)
  9. #define ALWAYS_INLINE __attribute__((always_inline)) inline
  10. #define NO_INLINE __attribute__((noinline))
  11. #define WEAK __attribute__((weak))
  12. #define PACKED __attribute__((packed))
  13. #define FIQ __attribute__((fiq("machine")))
  14. #define UNUSED(x) ((void)x)
  15. #define WDT_CLR() WDTCON = 0xa
  16. #define WDT_EN() WDTCON = 0x110
  17. #define WDT_DIS() WDTCON = 0xaa0
  18. #define WDT_RST() WDTCON = 0xa000110; while (1)
  19. #define WDT_RST_DELAY() WDTCON = 0xa100110; while (1)
  20. #define BYTE0(n) ((unsigned char)(n))
  21. #define BYTE1(n) ((unsigned char)((n)>>8))
  22. #define BYTE2(n) ((unsigned char)((n)>>16))
  23. #define BYTE3(n) ((unsigned char)((n)>>24))
  24. #define GET_LE16(ptr) (u16)(*(u16*)(u8*)(ptr))
  25. #define GET_LE32(ptr) (u32)(*(u32*)(u8*)(ptr))
  26. #define PUT_LE16(ptr, val) *(u16*)(u8*)(ptr) = (u16)(val)
  27. #define PUT_LE32(ptr, val) *(u32*)(u8*)(ptr) = (u32)(val)
  28. #define GET_BE16(ptr) get_be16(ptr)
  29. #define GET_BE32(ptr) get_be32(ptr)
  30. #define PUT_BE16(ptr, val) put_be16(ptr, val)
  31. #define PUT_BE32(ptr, val) put_be32(ptr, val)
  32. #define ALIGN4_HI(val) (((val)+3)&~3)
  33. #endif // _MACRO_H