Home2L - C/C++ API  v1.2-2-ga4fe (2023-04-15)
Smart Tools for a Private Home
Modules
Interface

Description

Specification of the microcontroller-host interface: two-wire bus protocol, register map, common constants etc. .

This is the general interface file for Home2L Brownies containing common definitions to be shared between Brownies and Linux hosts as well as everything related to the communication protocol.

This file is included by both the Linux and the AVR C (AVR==1) projects. All constants shared between Brownies and hosts are prefixed with 'BR_*'.

Collaboration diagram for Interface:

Modules

 Communication Protocol
 Communication message formats and Brownie status codes (EBrStatus).
 
 Brownie Memory
 Reference documentation of the Brownie virtual memory organization.
 
 Brownie Registers
 Reference documentation of the Brownie register map.
 

Time Constants and Conversion ...

The CPU frequency BR_CPU_FREQ must match the AVR compiler/linker setting of F_CPU.

The Brownie firmware uses a hardware timer (no regular timer interrupt) to measure time. The time unit is referred to as a Brownie Tick. The duration of a Brownie Tick is / should be in the order of one millisecond, but the exact duration somewhat depends on the hardware.

#define BR_CPU_FREQ   1000000
 CPU clock frequency.
 
#define BR_TICKS_PER_SECOND   (((float) BR_CPU_FREQ) / 1024.0)
 
#define BR_TICKS_PER_MS   (BR_TICKS_PER_SECOND / 1000.0)
 
#define BR_MS_PER_TICK   (1.0 / BR_TICKS_PER_MS)
 
#define BR_TICKS_OF_MS(T)   ((T) * BR_TICKS_PER_MS)
 
#define BR_MS_OF_TICKS(T)   (((float) (T)) * BR_MS_PER_TICK)
 
#define BR_TICKS_NEVER   0