yasimavr
Contents:
Command Line Usage
Key Concepts
Developer Reference
Examples
IDE Integration
yasimavr
yasimavr: arch_xt_io_utils.h Source File
View page source
arch_xt_io_utils.h Source File
yasimavr: arch_xt_io_utils.h Source File
yasimavr
Loading...
Searching...
No Matches
lib_arch_xt
src
arch_xt_io_utils.h
Go to the documentation of this file.
1
/*
2
* arch_xt_io_utils.h
3
*
4
* Copyright 2021-2026 Clement Savergne <csavergne@yahoo.com>
5
6
This file is part of yasim-avr.
7
8
yasim-avr is free software: you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation, either version 3 of the License, or
11
(at your option) any later version.
12
13
yasim-avr is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with yasim-avr. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
//=======================================================================================
23
24
25
#ifndef __YASIMAVR_XT_IO_UTILS_H__
26
#define __YASIMAVR_XT_IO_UTILS_H__
27
28
#include <stddef.h>
29
30
#define DEF_BITSPEC_F(field) \
31
bitspec_t(field ## _gp + bitmask_t(field ## _gm).bitcount() - 1, field ## _gp)
32
33
#define DEF_BITSPEC_B(bit) \
34
bitspec_t(bit ## _bp)
35
36
#define DEF_REGBIT_F(addr, field) \
37
regbit_t(REG_ADDR(addr), DEF_BITSPEC_F(field))
38
39
#define DEF_REGBIT_B(addr, bit) \
40
regbit_t(REG_ADDR(addr), DEF_BITSPEC_B(bit))
41
42
#define EXTRACT_F(reg, field) \
43
(((reg) & field ## _gm) >> field ## _gp)
44
45
#define EXTRACT_B(reg, bit) \
46
(((reg) & bit ## _bm) >> bit ## _bp)
47
48
#define EXTRACT_GC(reg, field) \
49
((reg) & field ## _gm)
50
51
#define READ_IOREG(reg) \
52
read_ioreg(REG_ADDR(reg))
53
54
#define READ_IOREG_F(reg, field) \
55
read_ioreg(REG_ADDR(reg), DEF_BITSPEC_F(field))
56
57
#define READ_IOREG_B(reg, bit) \
58
read_ioreg(REG_ADDR(reg), DEF_BITSPEC_B(bit))
59
60
#define READ_IOREG_F_GC(reg, field) \
61
(READ_IOREG(reg) & field ## _gm)
62
63
#define READ_IOREG_B_GC(reg, field) \
64
(READ_IOREG(reg) & field ## _bm)
65
66
#define WRITE_IOREG(reg, value) \
67
write_ioreg(REG_ADDR(reg), (value));
68
69
#define WRITE_IOREG_F(reg, field, value) \
70
write_ioreg(DEF_REGBIT_F(reg, field), (value))
71
72
#define WRITE_IOREG_B(reg, bit, value) \
73
write_ioreg(REG_ADDR(reg), DEF_BITSPEC_B(bit), (value))
74
75
#define WRITE_IOREG_F_GC(reg, field, gc_value) \
76
WRITE_IOREG_F(reg, field, (gc_value) >> field ## _gp)
77
78
#define WRITE_IOREG_B_GC(reg, field, gc_value) \
79
WRITE_IOREG_B(reg, field, (gc_value) >> field ## _bp)
80
81
#define TEST_IOREG(reg, bit) \
82
test_ioreg(REG_ADDR(reg), DEF_BITSPEC_B(bit))
83
84
#define SET_IOREG(reg, bit) \
85
set_ioreg(REG_ADDR(reg), DEF_BITSPEC_B(bit))
86
87
#define CLEAR_IOREG(reg, bit) \
88
clear_ioreg(REG_ADDR(reg), DEF_BITSPEC_B(bit))
89
90
91
#endif
//__YASIMAVR_XT_IO_UTILS_H__
Generated by
1.9.8