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
|
#ifndef MK20DX256_REG_REGDEFS_H
#define MK20DX256_REG_REGDEFS_H
#include <stdint.h>
#define REG_8(a) (*(volatile uint8_t *)(a))
#define REG_16(a) (*(volatile uint16_t *)(a))
#define REG_32(a) (*(volatile uint32_t *)(a))
#define REG_8_M(start, len) ((uint8_t)(BITS(len) << (start)))
#define REG_16_M(start, len) ((uint16_t)(BITS(len) << (start)))
#define REG_32_M(start, len) ((uint32_t)(BITS(len) << (start)))
#define BV(b) (1 << (b))
#define IS_BIT_SET(reg, bit) (!!((reg) & BV(bit)))
#define WAIT_BIT_UNSET(reg, bit) do { } while (IS_BIT_SET(reg, bit))
#define WAIT_BIT_SET(reg, bit) do { } while (!IS_BIT_SET(reg, bit))
#define SET_BIT(reg, bit) ((reg) |= BV(bit))
#define UNSET_BIT(reg, bit) ((reg) &= ~BV(bit))
#define GET_BIT(reg, bit) !!((reg) & BV(bit))
#define GET_BITS(reg, offset) (((reg) & (offset ## _M)) >> (offset))
#define SET_MASKED(reg, mask, bits) ((reg) = ((reg) & ~(mask)) | ((bits) & (mask)))
#define BITS(n) (0xffffffff >> (32 - (n)))
#endif /* MK20DX256_REG_REGDEFS_H */
|