HWA
Bare metal programming with style
|
These definitions can be used to add HWA support to a device.
Modules | |
Class _r16 | |
Class _r32 | |
Class _cb1 | |
Class _cb2 | |
Class _ob1 | |
Class _ob2 | |
Class _xb1 | |
Class _xb2 | |
Class _m11 | |
Class _m12 | |
Class _m22 | |
Class _fake | |
Macros | |
#define | _hw(...) |
#define | _hw_a(...) |
#define | _HW_B(...) |
#define | _HW_BZ(...) |
#define | _HW_COD(o) |
#define | _hw_par(...) |
#define | _hwa(...) |
#define | HW(...) |
#define | HW_A0(...) |
#define | HW_A1(...) |
#define | HW_AD(x, ...) |
#define | HW_ANAME(x, ...) |
#define | HW_AP(...) |
#define | HW_B(...) |
#define | HW_BED(f, x, ...) |
#define | HW_BEZ(f, x, ...) |
#define | HW_BP(f, x) |
#define | HW_BV(f, p, s, ...) |
#define | HW_BW(...) |
#define | HW_BX(...) |
#define | HW_C3(...) |
#define | hw_class__irq |
#define | hw_class__obj |
#define | HW_CODG(...) |
#define | HW_CODR(c, o, ...) |
#define | HW_D3(...) |
#define | HW_E(...) |
#define | HW_EAT(...) |
#define | HW_EOL(...) |
#define | HW_F(...) |
#define | hw_fake |
#define | HW_FC(...) |
#define | HW_G2(...) |
#define | HW_G3(...) |
#define | HW_IS(...) |
#define | HW_ISR(...) _HW_ISR0(__VA_ARGS__,,,) |
#define | HW_OXR(...) |
#define | hw_pin |
#define | HW_Q(...) |
#define | HW_RP(...) |
#define | HW_SHOW(x) |
#define | HW_TL(...) |
#define | HW_VF(...) |
#define | HW_X(...) |
#define | HW_XO(o) |
#define | HW_XOR(o, r) |
#define | HW_XS(x, ...) |
#define | HWA_E(...) |
#define | hwx(h, f, x, ...) |
#define _hw | ( | ... | ) |
Private version of hw().
#define _hw_a | ( | ... | ) |
Second version of _hwa().
Useful for external objects (such as HW_SWUARTA) that configure themselves their objects.
#define _HW_B | ( | ... | ) |
Branch depending on a void element.
_HW_B(f,x,...) expands to:
#define _HW_BZ | ( | ... | ) |
Branch depending on a void element. Does not handle parentheses.
_HW_BZ(f,x,...) expands to:
#define _HW_COD | ( | o | ) |
Get the definition of object o
as c,o,(d). No error checking.
See HW_XO() for error checking.
#define _hw_par | ( | ... | ) |
Detect an argument surrounded by parentheses.
#define _hwa | ( | ... | ) |
Private version of hwa().
#define HW | ( | ... | ) |
Get the definition of an object or a function name from a path.
This is used for example to get the "putchar" function name of a LCD: HW(LCD,putchar)
#define HW_A0 | ( | ... | ) |
Element a0 of the list a0,...
#define HW_A1 | ( | ... | ) |
Element a1 of the list a0,a1,...
#define HW_AD | ( | x, | |
... | |||
) |
Reduce the definition of the object in first position to one single element in parentheses: '(c,o,d)'.
#define HW_ANAME | ( | x, | |
... | |||
) |
Replace the definition of an object by its name in the beginning of a list.
This is used by functions that accept HWA-built objects as arguments, such as HW_SWTWIMASTER. The functions get the definition instead of the object name.
#define HW_AP | ( | ... | ) |
HW_AP(logical_register)
returns the pair address,position of a logical register.
This is useful for assembly programming, for example with the SBI / CBI instructions.
#define HW_B | ( | ... | ) |
#define HW_BED | ( | f, | |
x, | |||
... | |||
) |
Branch depending on the expansion of a definition.
HW_BED(f,x,...) expands to:
#define HW_BEZ | ( | f, | |
x, | |||
... | |||
) |
Branch depending on an expansion starting with void.
HW_BEZ(f,x,...) expands to:
#define HW_BP | ( | f, | |
x | |||
) |
#define HW_BV | ( | f, | |
p, | |||
s, | |||
... | |||
) |
Branch depending on a value.
HW_BV(f,p,s,...) expands to:
f_(s,...)
if s
is '(...)'.f0(s,...)
if the expansion of _hw_<p><s>
does not start with a void.f1(r,...)
where r
is the 2nd and following elements of the expansion of _hw_<p><s>
.Example:
#define HW_BW | ( | ... | ) |
Branch depending on a word.
HW_BW(f,k,w) expands to:
#define
_hw_is_k_k , 1)#define HW_BX | ( | ... | ) |
Branch depending on a void result after appending p and x:
HW_BX(f,p,x,...) expands to:
#define hw_class__obj |
Generic object class.
#define HW_CODG | ( | ... | ) |
Get the memory definition of register r
of object o
.
FIXME: to be continued.
#define HW_CODR | ( | c, | |
o, | |||
... | |||
) |
Get the definition of the relative r of object o as a triplet: 'c,o_r,(d)' or 'c,(o,r),(d)'.
Expands to ',o,error message' if the relative r can not be found. Register definitions are finally converted to memory definitions.
#define HW_D3 | ( | ... | ) |
Put parentheses around arguments of a definition from 3rd position on.
#define HW_E | ( | ... | ) |
Trigger an error at preprocessing stage.
Error handling is based on the C99 _Pragma operator. It produces a preprocessing error as soon as the _Pragma(...) sentence is emitted, be it inside or outside of a C function definition, or in an assembler source.
Error messages are produced by HW_EM() macros so that they can be localized easily.
#define HW_EAT | ( | ... | ) |
Eliminates arguments.
Used when a parsing fails and remaining arguments have been pushed.
#define HW_EOL | ( | ... | ) |
Trigger an error if the first argument is not void.
This is used to ensure that there is no remaining elements in a list at the end of its parsing.
#define HW_F | ( | ... | ) |
Find a function f for object o and call it.
Call f_E(e) with an error message if an error occurs. It's up to f_E to produce an error (or not).
The method is searched in this order:
The definition of the object is pushed away with the arguments of the method.
#define HW_FC | ( | ... | ) |
Specialize instruction f
for class c
HW_FC(f,c,...) -> fc(...) Arguments must start with a class name that is to be appended to the function name.
#define HW_IS | ( | ... | ) |
Expands to 1 if the first two elements of the list are defined equal, 0 otherwise.
For that to work, HW_IS()
must be used as HW_IS(x,y)
and there must be a definition of _hw_is_x_y
that expands as ', 1
'
FIXME: should probably remove this and use branches instead.
#define HW_ISR | ( | ... | ) | _HW_ISR0(__VA_ARGS__,,,) |
Declare an ISR.
#define HW_OXR | ( | ... | ) |
Convert a register definition to a memory definition.
#define hw_pin |
The virtual object 'pin' handles the '(pin,...)' notation.
#define HW_Q | ( | ... | ) |
Build a C string from a list of elements.
#define HW_RP | ( | ... | ) |
Remove parentheses.
#define HW_TL | ( | ... | ) |
Elements a1,... of the list a0,a1,...
#define HW_VF | ( | ... | ) |
Expand the argument to a function call.
The first argument is ignored, the second is the name of the function, the third is the argument of the function.
#define HW_X | ( | ... | ) |
Parse a path and return the definition as: c,o,...
Up to 5 elements can be put in the path.
First element can be:
o
If an error occurs, ',o,error message' is returned.
#define HW_XO | ( | o | ) |
Get the definition of an object named 'o' as a triplet: c,o,(d).
Expands to ,o,"error message" if o is not an object.
#define HW_XOR | ( | o, | |
r | |||
) |
Expand the definition of register r of object o.
No error checking. r must be a register of object o, not a class register.
#define hwx | ( | h, | |
f, | |||
x, | |||
... | |||
) |
Find a method for an object and call it.
The method is searched in this order:
FIXME: using the object name to distinguish a no-object call and an error-object call. A class _err would be faster?