X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Futil.h;h=18e36524b422304b6ec1b0aa98e5bd0e8486dcc9;hb=bb37203461a4380e32be26594a74b77727dda97d;hp=f7fe61dd935e1b4ed59453dcd04d738ac5202dfa;hpb=dd1616dba9eadf3b0d553b545e0d42eadac808cd;p=home-hw.git diff --git a/lib/util.h b/lib/util.h index f7fe61d..18e3652 100644 --- a/lib/util.h +++ b/lib/util.h @@ -24,6 +24,7 @@ typedef int32_t s32; #define MIN(x,y) ((x) < (y) ? (x) : (y)) #define MAX(x,y) ((x) > (y) ? (x) : (y)) #define CLAMP(x,min,max) ({ typeof(x) _t=x; (_t < min) ? min : (_t > max) ? max : _t; }) +#define ARRAY_SIZE(ary) (sizeof(ary)/sizeof((ary)[0])) #define UNUSED __attribute__((unused)) @@ -84,11 +85,19 @@ static inline void wait_for_interrupt(void) asm volatile ("wfi"); } +// A compiler memory barrier + +static inline void barrier(void) +{ + asm volatile ("" : : : "memory"); +} + // util-debug.c void debug_printf(const char *fmt, ...) __attribute__((format(printf,1,2))); void debug_puts(const char *s); void debug_putc(int c); +void debug_flush(void); void debug_led(bool light); void debug_led_toggle(void);