
Aquamaniac Home Control System (AqHCS) uses a minimalistic operating system.

That OS doesn't use devicer driver object structures due to RAM contraints, it just defines a few
callback labels which need to be provided by drivers, apps and the main code.

Main routines for drivers are:
- Init
- Fini (not used for now)
- Run
- OnEvery100ms
- OnMessageReceived

This system is event driven. There is one single main loop which uses some defined labels as callbacks.

Basically the main loop works like this:

--------------------------------------------------------------------------------------------------------X8
loop:
  - sleep (waiting to be awakended by interrupt)
  - call RUN routines of every active driver
  - call onEveryLoop
  - goto loop
--------------------------------------------------------------------------------------------------------X8


The main RUN routine consists of a number of calls to RUN functions of used drivers and apps, e.g.:

--------------------------------------------------------------------------------------------------------X8
RunDrivers:
    call BaseTimer_Run   ; main clock event source
#ifdef MODULES_TTYONUART1
    call TtyOnUart1_Run
#endif
#ifdef MODULES_COM2WI
    call COM2WI_Run
#endif
    ret
--------------------------------------------------------------------------------------------------------X8

This means new drivers have their RUN functions registered by adding them to the RunDrivers routine with
"#ifdef" clauses around them. That way you only need to add the line "#define MODULES_TTYONUART1" in your main
application to have the driver automatically used.


The main driver of the system is the BaseTimer module. It is supplied by interrupt of an AVR timer circuit.
Its RUN routine then calls some other routines in the main app like "onEverySecond" etc.


Required labels for the main application are:

- onSystemStart:     called first after system start
- onMessageReceived: called for every network package received
- onEvery100ms:      called every 100ms which is the base clock for all other functions
- onEverySecond:     called every second
- onEveryMinute:     called every minute
- onEveryHour:       called every hour
- onEveryDay:        called every day
- onEveryLoop:       called on every main loop

These callbacks must all be defined in the main source file but callbacks for functionality not provided or used by the main 
system might just execute a "ret" instruction.




