aboutsummaryrefslogtreecommitdiff
path: root/common.h
blob: 5957da3ab97d7ab88f3ca5bc51e9c59db0eb1b53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef COMMON_H
#define COMMON_H

/* cpu runs at n mhz */
#define F_CPU 8000000

#define sleepwhile(cond) \
	sleep_enable (); \
	while (cond) { sleep_cpu (); } \
	sleep_disable ();

#define __unused__ __attribute__ ((unused))

/* define lightweight assert (without printf) that halts the cpu */
#include <stdio.h>
#include <avr/sleep.h>
#include <avr/interrupt.h>
#define assert(x) if (!(x)) { \
		puts("assert in " __FILE__ ":" #x); \
		sleep_enable (); \
		while (1) { \
			sleep_cpu (); \
		} \
	}

#endif /* COMMON_H */