FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
memory.h
Go to the documentation of this file.
1// Copyright 2016-2023 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
16
21#ifndef MEMORY_H
22#define MEMORY_H
23
24#include <stdint.h>
25#include "gpio.h"
26
28extern int __heap_start;
29extern int* __brkval;
31
35namespace memory
36{
41 {
42 int v;
43 return (int) &v - (__brkval == nullptr ? (int) &__heap_start : (int) __brkval);
44 }
45
54 bool check_mem(int minimum)
55 {
56 return free_mem() > minimum;
57 }
58
67 void alert_mem(int minimum)
68 {
69 if (check_mem(minimum))
71 else
73 }
74}
75
76#endif /* MEMORY_H */
static void set()
Set pin level to HIGH (i.e.
Definition: gpio.h:596
static void clear()
Set pin level to LOW (i.e.
Definition: gpio.h:605
General Purpose (digital) Input Output API.
Contains a few utility method to deal with free SRAM memory.
Definition: memory.h:36
bool check_mem(int minimum)
Check if current free SRAM memory is above the provided minimum.
Definition: memory.h:54
int free_mem()
Return the amount of free SRAM memory.
Definition: memory.h:40
void alert_mem(int minimum)
Check if current free SRAM memory is above the provided minimum.
Definition: memory.h:67