HWA
Bare metal programming with style
iob_1.h
Go to the documentation of this file.
1
2
/* This file is part of the HWA project.
3
* Copyright (c) 2021 Christophe Duparquet.
4
* All rights reserved. Read LICENSE.TXT for details.
5
*/
6
19
#define hw_class__iob
20
21
30
#define hw__iob_port , _hw_iob_port
31
#define _hw_iob_port(o,p,...) _hw_iob_port1(p,hw_##p)
32
#define _hw_iob_port1(...) _hw_iob_port2(__VA_ARGS__)
33
#define _hw_iob_port2(p,c,...) c,p,(__VA_ARGS__)
34
35
55
#define HW_ADDRESS__iob , _hw_adiob
56
#define _hw_adiob(o,p,bn,bp,...) _hw_adiob01(hw_##p,bn,bp)
57
#define _hw_adiob01(...) _hw_adiob02(__VA_ARGS__)
58
#define _hw_adiob02(c,a,bn,bp) (a+(bn-1)*16+bp)
59
70
#define HW_BITS__iob , _hw_btiob
71
#define _hw_btiob(o, cn,bn,bp,...) bn
72
73
84
#define HW_POSITION__iob , _hw_pniob
85
#define _hw_pniob(o, cn,bn,bp,...) bp
86
87
88
/* Access 'mode' bits in crl/crh from a pin. [_HW_OX26]
89
*/
90
/* #define hw__iob_mode , _hw_iob_mode */
91
92
/* #define _hw_iob_mode(...) _hw_iob_mode10(__VA_ARGS__) */
93
/* #define _hw_iob_mode10(o,p,bn,bp) HW_B(_hw_iob_mode10_,_hw_is_1_##bn)(o,p,bn,bp) */
94
/* #define _hw_iob_mode10_0(o,p,bn,bp) ,o,HW_EM(is not a single pin) */
95
/* #define _hw_iob_mode10_1(o,p,bn,bp) _hw_iob_mode20(bp,hw__gpa_mode##bp,p,hw_##p) */
96
/* #define _hw_iob_mode20(...) _hw_iob_mode21(__VA_ARGS__) */
97
/* #define _hw_iob_mode21(bp,rc,r,rbn,rbp,p,pc,pa) HW_OXR(rc,,r,rbn,rbp,pc,p,pa) */
98
99
100
/* Access 'cnf' bits in crl/crh from a pin. [_HW_OX26]
101
*/
102
/* #define hw__iob_cnf , _hw_iob_cnf */
103
104
/* #define _hw_iob_cnf(...) _hw_iob_cnf10(__VA_ARGS__) */
105
/* #define _hw_iob_cnf10(o,p,bn,bp) HW_B(_hw_iob_cnf10_,_hw_is_1_##bn)(o,p,bn,bp) */
106
/* #define _hw_iob_cnf10_0(o,p,bn,bp) ,o,HW_EM("is not a single pin") */
107
/* #define _hw_iob_cnf10_1(o,p,bn,bp) _hw_iob_cnf20(bp,hw__gpa_cnf##bp,p,hw_##p) */
108
/* #define _hw_iob_cnf20(...) _hw_iob_cnf21(__VA_ARGS__) */
109
/* #define _hw_iob_cnf21(bp,rc,r,rbn,rbp,p,pc,pa) HW_OXR(rc,,r,rbn,rbp,pc,p,pa) */
110
111
112
/* Accept to append a number to a _iob definition so that:
113
* * (portx,n) becomes a single pin at position n of portx.
114
* * (portx,n,p) becomes a set of n consecutive pins at position p of portx.
115
*/
116
#define hw__iob_ , _hw_iob_
117
#define _hw_iob_(o,r,p,bn,bp) _HW_B(_hw_iob_,_hw_is_1_##bn)(o,r,p,bn,bp)
118
#define _hw_iob_0(o,r,...) ,(o,r),HW_EM(o has no relative r)
119
#define _hw_iob_1(o,r,p,bn,bp) _HW_B(_hw_iob1_,_hw_isa_4bn_##r)(o,r,p,bn,bp)
120
#define _hw_iob1_1(o,r,p,bn,bp) _iob,p##_##bp##_##r,(p,bp,r)
121
#define _hw_iob1_0(o,r,p,bn,bp) _hw_iob10(o,r,p,bn,bp,hw_##p##_##bn##_##bp##_##r)
122
#define _hw_iob10(...) _hw_iob11(__VA_ARGS__)
123
#define _hw_iob11(o,r,p,bn,bp,...) _HW_B(_hw_iob2,_hw_isa_reg_##__VA_ARGS__)(o,r,p,bn,bp,__VA_ARGS__)
124
#define _hw_iob21(o,r,p,bn,bp,cr,...) HW_OXR(cr,r,__VA_ARGS__,_iob,o,__VA_ARGS__)
125
#define _hw_iob20(o,r,p,bn,bp,...) _hw_iob22(o,r,p,bn,bp,HW_XO(__VA_ARGS__))
126
#define _hw_iob22(...) _hw_iob23(__VA_ARGS__)
127
#define _hw_iob23(o,r,p,bn,bp,x,...) _HW_B(_hw_iob23,x)(o,r,p,bn,bp,x,__VA_ARGS__)
128
#define _hw_iob231(o,r,p,bn,bp,...) ,(o),HW_EM(o has no relative r)
129
#define _hw_iob230(o,r,p,bn,bp,...) __VA_ARGS__
Generated for HWA by
1.8.6