Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NodeManager_GasSensor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SmartHome
NodeManager_GasSensor
Commits
75be0801
Commit
75be0801
authored
7 years ago
by
Reinhold Kainhofer
Browse files
Options
Downloads
Patches
Plain Diff
Add debug statements printing out free memory
parent
e9bcd8ed
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
MemoryFree.cpp
+44
-0
44 additions, 0 deletions
MemoryFree.cpp
MemoryFree.h
+18
-0
18 additions, 0 deletions
MemoryFree.h
NodeManager.h
+2
-0
2 additions, 0 deletions
NodeManager.h
with
64 additions
and
0 deletions
MemoryFree.cpp
0 → 100644
+
44
−
0
View file @
75be0801
#if (ARDUINO >= 100)
#include
<Arduino.h>
#else
#include
<WProgram.h>
#endif
extern
unsigned
int
__heap_start
;
extern
void
*
__brkval
;
/*
* The free list structure as maintained by the
* avr-libc memory allocation routines.
*/
struct
__freelist
{
size_t
sz
;
struct
__freelist
*
nx
;
};
/* The head of the free list structure */
extern
struct
__freelist
*
__flp
;
#include
"MemoryFree.h"
/* Calculates the size of the free list */
int
freeListSize
()
{
struct
__freelist
*
current
;
int
total
=
0
;
for
(
current
=
__flp
;
current
;
current
=
current
->
nx
)
{
total
+=
2
;
/* Add two bytes for the memory block's header */
total
+=
(
int
)
current
->
sz
;
}
return
total
;
}
int
freeMemory
()
{
int
free_memory
;
if
((
int
)
__brkval
==
0
)
{
free_memory
=
((
int
)
&
free_memory
)
-
((
int
)
&
__heap_start
);
}
else
{
free_memory
=
((
int
)
&
free_memory
)
-
((
int
)
__brkval
);
free_memory
+=
freeListSize
();
}
return
free_memory
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
MemoryFree.h
0 → 100644
+
18
−
0
View file @
75be0801
// MemoryFree library based on code posted here:
// http://forum.arduino.cc/index.php?topic=27536.msg204024#msg204024
// Extended by Matthew Murdoch to include walking of the free list.
#ifndef MEMORY_FREE_H
#define MEMORY_FREE_H
#ifdef __cplusplus
extern
"C"
{
#endif
int
freeMemory
();
#ifdef __cplusplus
}
#endif
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
NodeManager.h
+
2
−
0
View file @
75be0801
...
...
@@ -12,6 +12,8 @@
void
printFM
();
void
printFM
();
/***********************************
Constants
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment