HWA
Bare metal programming with style
Miscellaneous

Detailed Description

Macros

#define HW_ATOMIC(...)
 
#define HW_MEM_EEPROM   __attribute__((section(".eeprom")))
 
#define hw_wait_irq   , _hw_wait_irq
 
#define hw_waste_cycles(n)   __builtin_avr_delay_cycles(n)
 

Macro Definition Documentation

◆ HW_ATOMIC

#define HW_ATOMIC (   ...)
Value:
do{ \
uint8_t s = _hw_read(core0,sreg); \
hw_disable, interrupts(); \
{ __VA_ARGS__ } \
_hw_write(core0,sreg,s) ; \
}while(0)

Execute a block with interrupts disabled

◆ HW_MEM_EEPROM

#define HW_MEM_EEPROM   __attribute__((section(".eeprom")))
Tell the linker to put data in EEPROM memory segment
static uint16_t HW_MEM_EEPROM numbers[16] ; // 16 16-bit numbers in EEPROM
Examples
hwa/atmel/avr/examples/99-02-TCS3200-color-detector/main.c.

◆ hw_wait_irq

#define hw_wait_irq   , _hw_wait_irq
Wait for an interrupt (sleep until an interrupt occurs)
hw( wait, irq );

◆ hw_waste_cycles

#define hw_waste_cycles (   n)    __builtin_avr_delay_cycles(n)

Software loop of n CPU clock cycles (only works with compile-time constants).

hw_waste_cycles( 0.5 * HW_SYSHZ ); // At least 0.5 s
Examples
hwa/st/stm32/examples/05-2-uart/main.c.
hw
#define hw(...)
hw( action, object [,...] ) executes an action immediately on an object.
Definition: hwa_macros.h:523
_hw_read
#define _hw_read(o, r)
Read one register of an object.
Definition: hwa_2.h:140
hw_waste_cycles
#define hw_waste_cycles(n)
Definition: hwa_2.h:98
HW_MEM_EEPROM
#define HW_MEM_EEPROM
Definition: hwa_2.h:146