You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

24 lines
536 B

  1. #ifndef UTIL_H
  2. #define UTIL_H
  3. #include "config.h"
  4. /* Convert from ascii hex digit to number */
  5. uint8_t from_hex(uint8_t ch);
  6. extern const uint8_t hex[16];
  7. /* Array length */
  8. #define array_len(x) (sizeof(x)/sizeof(x[0]))
  9. /* ISR disable/enable with saving of previous state */
  10. #define __int_top() int __sr_save
  11. #define __int_disable() __sr_save=SR; SRbits.IPL=7
  12. #define __int_enable() SR=__sr_save
  13. #define disable_int(x) do { \
  14. __int_top(); \
  15. __int_disable(); \
  16. x; \
  17. __int_enable(); } while(0)
  18. #endif