-
Notifications
You must be signed in to change notification settings - Fork 1
/
glob_def.h
47 lines (33 loc) · 899 Bytes
/
glob_def.h
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* glob_def.h
*
* Created: 11.06.2021 12:14:11
* Author: LD
*/
#ifndef GLOB_DEF_H_
#define GLOB_DEF_H_
#include <stdbool.h>
#include <stddef.h>
#ifndef F_CPU
#define F_CPU 16000000UL // 16 MHZ
#endif /* F_CPU */
#ifndef BAUD
#define BAUD 9600UL
#endif /* BAUD */
#define _delay_s(__s) _delay_ms((__s)*1000)
#define BIT(x) (1 << (x))
#define _ON(x, y) (x |= BIT(y))
#define _OFF(x, y) (x &= ~BIT(y))
#define _TOGGLE(x, y) (x ^= BIT(y))
#define _GET(x,y) (!(x & BIT(y)))
#define _SET(x,y,z) if(x) _ON(y,z); else _OFF(y ,z)
#define OUTPUT(x) _ON(_ ## x ## _ ,x)
#define INPUT(x) _OFF(_ ## x ## _ ,x)
#define ON(x) _ON(_ ## x ,x)
#define OFF(x) _OFF(_ ## x,x)
#define TOGGLE(x) _TOGGLE(_ ## x ,x)
#define GET(x) _GET(__ ## x, x)
#define SET(x,y) if(x) _ON(_ ## y,y); else _OFF(_ ## y ,y)
#define GETBIT(x,y) (((x)>>(y))%2)
typedef unsigned char byte;
#endif /* GLOB_DEF_H_ */