utils.h 609 B

123456789101112131415161718192021222324252627282930
  1. #ifndef _UTILS_H__
  2. #define _UTILS_H__
  3. #include "os/os_type.h"
  4. #include "os/co_task.h"
  5. #define delay_us cpu_udelay
  6. static __inline__ void delay_ms(u32 ms) {
  7. cpu_udelay(ms*1000);
  8. }
  9. static __inline__ u16 DECODE_U16(u8 *buff) {
  10. return (((u16)(buff[1]) << 8) | buff[0]);
  11. }
  12. static __inline__ u32 DECODE_U24(u8 *buff) {
  13. return ((u32)(buff[2]) << 16 | DECODE_U16(buff));
  14. }
  15. static __inline__ u16 DECODE_U32(u8 *buff) {
  16. return ((u32)(buff[3]) << 24 | DECODE_U24(buff));
  17. }
  18. #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
  19. #define min(a,b) (a>b?b:a)
  20. #define MAX(x, y) ((x)>(y)?(x):(y))
  21. #endif /* _UTILS_H__ */