HWA
Bare metal programming with style
Definitions for HWA developers

Detailed Description

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, ...)
 

Macro Definition Documentation

◆ _hw

#define _hw (   ...)

Private version of hw().

◆ _hw_a

#define _hw_a (   ...)

Second version of _hwa().

Useful for external objects (such as HW_SWUARTA) that configure themselves their objects.

◆ _HW_B

#define _HW_B (   ...)

Branch depending on a void element.

_HW_B(f,x,...) expands to:

  • f1 if x is void
  • f0 otherwise Unlike HW_B, this version does not handle parentheses.

◆ _HW_BZ

#define _HW_BZ (   ...)

Branch depending on a void element. Does not handle parentheses.

_HW_BZ(f,x,...) expands to:

  • f1 if x is void
  • f0 otherwise

◆ _HW_COD

#define _HW_COD (   o)

Get the definition of object o as c,o,(d). No error checking.

See HW_XO() for error checking.

◆ _hw_par

#define _hw_par (   ...)

Detect an argument surrounded by parentheses.

◆ _hwa

#define _hwa (   ...)

Private version of hwa().

◆ HW

#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)

Examples
hwa/atmel/avr/examples/99-03-HD44780-PCF8574/main.c.

◆ HW_A0

#define HW_A0 (   ...)

Element a0 of the list a0,...

◆ HW_A1

#define HW_A1 (   ...)

Element a1 of the list a0,a1,...

◆ HW_AD

#define HW_AD (   x,
  ... 
)

Reduce the definition of the object in first position to one single element in parentheses: '(c,o,d)'.

◆ HW_ANAME

#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.

◆ HW_AP

#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.

◆ HW_B

#define HW_B (   ...)

Branch depending on a void element.

HW_B(f,c) expands to:

  • f##1 if c is void
  • f##0 otherwise

◆ HW_BED

#define HW_BED (   f,
  x,
  ... 
)

Branch depending on the expansion of a definition.

HW_BED(f,x,...) expands to:

  • f1(...,{definition of x}) if x expands to the definition of an object
  • f0(...,x) otherwise

◆ HW_BEZ

#define HW_BEZ (   f,
  x,
  ... 
)

Branch depending on an expansion starting with void.

HW_BEZ(f,x,...) expands to:

  • f1(...,{expansion of x}) if x expands to ' , ...'
  • f0(...,x) otherwise

◆ HW_BP

#define HW_BP (   f,
 
)

Branch depending on a parenthesis element.

HW_BP(f,x) expands to:

  • f1 if x is '(...)'
  • f0 otherwise

◆ HW_BV

#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:

// The following code provides the following expansions:
//
// fun((foo),bar) -> fun_((foo),x) (bar)
// fun(foo,bar) -> fun0(foo,x) (bar)
// fun(yes,bar) -> fun1(yesval,x) (bar)
//
#define fun(v,...) HW_BV(fun,funval_,v,x)(__VA_ARGS__)
#define _hw_funval_yes , yesval

◆ HW_BW

#define HW_BW (   ...)

Branch depending on a word.

HW_BW(f,k,w) expands to:

  • f0 if k is not w
  • f1 if k is w (there must a: #define _hw_is_k_k , 1)
#define _hw_is_key_key , 1
HW_BW(func,key,word) -> func0
HW_BW(func,key,key) -> func1

◆ HW_BX

#define HW_BX (   ...)

Branch depending on a void result after appending p and x:

HW_BX(f,p,x,...) expands to:

  • f1 if px is void
  • f0 otherwise

◆ hw_class__obj

#define hw_class__obj

Generic object class.

◆ HW_CODG

#define HW_CODG (   ...)

Get the memory definition of register r of object o.

FIXME: to be continued.

◆ HW_CODR

#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.

◆ HW_D3

#define HW_D3 (   ...)

Put parentheses around arguments of a definition from 3rd position on.

◆ HW_E

#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.

Note
The preprocessor expands _Pragma(...) as a void token.

Error messages are produced by HW_EM() macros so that they can be localized easily.

◆ HW_EAT

#define HW_EAT (   ...)

Eliminates arguments.

Used when a parsing fails and remaining arguments have been pushed.

◆ HW_EOL

#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.

◆ HW_F

#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:

  1. f_c
  2. f_o
  3. f

The definition of the object is pushed away with the arguments of the method.

◆ HW_FC

#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.

◆ HW_IS

#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.

◆ HW_ISR

#define HW_ISR (   ...)    _HW_ISR0(__VA_ARGS__,,,)

◆ HW_OXR

#define HW_OXR (   ...)

Convert a register definition to a memory definition.

  • _m11,(o,r),(o,r,rc,a,wm,fm,bn,bp)
  • _m12,(o,r),(o,r,rc,a,wm,fm,bn1,bp1,vp1,bn2,bp2,vp2)
  • _m22,(o,r),(o,r1,rc1,a1,wm1,fm1,bn1,bp1,vp1,r2,rc2,a2,wm2,fm2,bn2,bp2,vp2)

◆ hw_pin

#define hw_pin

The virtual object 'pin' handles the '(pin,...)' notation.

◆ HW_Q

#define HW_Q (   ...)

Build a C string from a list of elements.

Examples
hwa/atmel/avr/examples/03-6-fade-counter-compare-output/main.c.

◆ HW_RP

#define HW_RP (   ...)

Remove parentheses.

◆ HW_TL

#define HW_TL (   ...)

Elements a1,... of the list a0,a1,...

◆ HW_VF

#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.

◆ HW_X

#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:

  • a single word: o
  • a definition: c,o,(d)
  • a path: (...) following elements must be object names.

If an error occurs, ',o,error message' is returned.

◆ HW_XO

#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.

◆ HW_XOR

#define HW_XOR (   o,
 
)

Expand the definition of register r of object o.

No error checking. r must be a register of object o, not a class register.

◆ hwx

#define hwx (   h,
  f,
  x,
  ... 
)

Find a method for an object and call it.

The method is searched in this order:

  1. A class method, h_f_c
  2. A global method, h_f
  3. A class method h_f_ if 'o' is void (begin,commit...)

FIXME: using the object name to distinguish a no-object call and an error-object call. A class _err would be faster?

HW_BW
#define HW_BW(...)
Branch depending on a word.
Definition: hwa_macros.h:217