MySensors Library & Examples  2.3.2
Macros | Typedefs | Functions
MyHwHAL.h File Reference

Detailed Description

MySensors hardware abstraction layer

Definition in file MyHwHAL.h.

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define INVALID_INTERRUPT_NUM   (0xFFu)
 Invalid interrupt.
 
#define MY_HWID_PADDING_BYTE   (0xAAu)
 HwID padding byte.
 
#define IRQ_HANDLER_ATTR
 ESP8266/ESP32 IRQ handlers need to be stored in IRAM.
 
#define MY_CRITICAL_SECTION
 Creates a block of code that is guaranteed to be executed atomically. Upon entering the block all interrupts are disabled, and re-enabled upon exiting the block from any exit path. A typical example that requires atomic access is a 16 (or more) bit variable that is shared between the main execution path and an ISR, on an 8-bit platform (e.g AVR): More...
 
#define MY_HW_HAS_GETENTROPY
 Define this, if hwGetentropy is implemented. More...
 

Typedefs

typedef uint8_t unique_id_t[16]
 unique ID
 

Functions

int8_t hwSleep (uint32_t ms)
 
int8_t hwSleep (const uint8_t interrupt, const uint8_t mode, uint32_t ms)
 
int8_t hwSleep (const uint8_t interrupt1, const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2, uint32_t ms)
 
bool hwUniqueID (unique_id_t *uniqueID)
 
uint16_t hwCPUVoltage (void)
 
uint16_t hwCPUFrequency (void)
 
int8_t hwCPUTemperature (void)
 
uint16_t hwFreeMem (void)
 

Macro Definition Documentation

◆ MY_CRITICAL_SECTION

#define MY_CRITICAL_SECTION

Creates a block of code that is guaranteed to be executed atomically. Upon entering the block all interrupts are disabled, and re-enabled upon exiting the block from any exit path. A typical example that requires atomic access is a 16 (or more) bit variable that is shared between the main execution path and an ISR, on an 8-bit platform (e.g AVR):

volatile uint16_t val = 0;
void interrupHandler()
{
val = ~val;
}
void loop()
{
uint16_t copy_val;
{
copy_val = val;
}
}

All code within the MY_CRITICAL_SECTION block will be protected from being interrupted during execution.

Definition at line 183 of file MyHwHAL.h.

◆ MY_HW_HAS_GETENTROPY

#define MY_HW_HAS_GETENTROPY

Define this, if hwGetentropy is implemented.

ssize_t hwGetentropy(void *__buffer, size_t __length);

Definition at line 184 of file MyHwHAL.h.

Function Documentation

◆ hwCPUFrequency()

uint16_t hwCPUFrequency ( void  )

CPU frequency

Returns
CPU frequency in 1/10Mhz

◆ hwCPUTemperature()

int8_t hwCPUTemperature ( void  )

CPU temperature (if available) Adjust calibration parameters via MY_<ARCH>_TEMPERATURE_OFFSET and MY_<ARCH>_TEMPERATURE_GAIN

Returns
CPU temperature in °C, -127 if not available

◆ hwCPUVoltage()

uint16_t hwCPUVoltage ( void  )

CPU voltage

Returns
CPU voltage in mV

◆ hwFreeMem()

uint16_t hwFreeMem ( void  )

Report free memory (if function available)

Returns
free memory in bytes

◆ hwSleep() [1/3]

int8_t hwSleep ( const uint8_t  interrupt,
const uint8_t  mode,
uint32_t  ms 
)

Sleep for a defined time, using minimum power, or until woken by interrupt.

Parameters
interruptInterrupt number, which can wake the mcu from sleep.
modeInterrupt mode, as passed to attachInterrupt.
msTime to sleep, in [ms].
Returns
MY_WAKE_UP_BY_TIMER when woken by timer, or interrupt number when woken by interrupt.

◆ hwSleep() [2/3]

int8_t hwSleep ( const uint8_t  interrupt1,
const uint8_t  mode1,
const uint8_t  interrupt2,
const uint8_t  mode2,
uint32_t  ms 
)

Sleep for a defined time, using minimum power, or until woken by one of the interrupts.

Parameters
interrupt1Interrupt1 number, which can wake the mcu from sleep.
mode1Interrupt1 mode, as passed to attachInterrupt.
interrupt2Interrupt2 number, which can wake the mcu from sleep.
mode2Interrupt2 mode, as passed to attachInterrupt.
msTime to sleep, in [ms].
Returns
MY_WAKE_UP_BY_TIMER when woken by timer, or interrupt number when woken by interrupt.

◆ hwSleep() [3/3]

int8_t hwSleep ( uint32_t  ms)

Sleep for a defined time, using minimum power.

Parameters
msTime to sleep, in [ms].
Returns
MY_WAKE_UP_BY_TIMER.

◆ hwUniqueID()

bool hwUniqueID ( unique_id_t uniqueID)

Retrieve unique hardware ID

Parameters
uniqueIDunique ID
Returns
True if unique ID successfully retrieved
Examples
SecurityPersonalizer.ino.
MY_CRITICAL_SECTION
#define MY_CRITICAL_SECTION
Creates a block of code that is guaranteed to be executed atomically. Upon entering the block all int...
Definition: MyHwHAL.h:183
loop
void loop(void) __attribute__((weak))
Main loop.
Definition: Echo.ino:28