macro.h 1.5 KB

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