Keep "astyled" elements in M100_*.cpp
This commit is contained in:
@@ -57,12 +57,10 @@ int how_many_E5s_are_here( unsigned char *);
|
||||
|
||||
|
||||
|
||||
void gcode_M100()
|
||||
{
|
||||
void gcode_M100() {
|
||||
static int m100_not_initialized = 1;
|
||||
unsigned char* sp, *ptr;
|
||||
int i, j, n;
|
||||
|
||||
//
|
||||
// M100 D dumps the free memory block from __brkval to the stack pointer.
|
||||
// malloc() eats memory from the start of the block and the stack grows
|
||||
@@ -72,11 +70,9 @@ int i, j, n;
|
||||
// probably caused by bad pointers. Any unexpected values will be flagged in
|
||||
// the right hand column to help spotting them.
|
||||
//
|
||||
|
||||
#if ENABLED(M100_FREE_MEMORY_DUMPER) // Disable to remove Dump sub-command
|
||||
if (code_seen('D')) {
|
||||
ptr = (unsigned char*) __brkval;
|
||||
|
||||
//
|
||||
// We want to start and end the dump on a nice 16 byte boundry even though
|
||||
// the values we are using are not 16 byte aligned.
|
||||
@@ -84,12 +80,10 @@ int i, j, n;
|
||||
SERIAL_ECHOPGM("\n__brkval : ");
|
||||
prt_hex_word((unsigned int) ptr);
|
||||
ptr = (unsigned char*)((unsigned long) ptr & 0xfff0);
|
||||
|
||||
sp = top_of_stack();
|
||||
SERIAL_ECHOPGM("\nStack Pointer : ");
|
||||
prt_hex_word((unsigned int) sp);
|
||||
SERIAL_ECHOPGM("\n");
|
||||
|
||||
sp = (unsigned char*)((unsigned long) sp | 0x000f);
|
||||
n = sp - ptr;
|
||||
//
|
||||
@@ -103,7 +97,6 @@ int i, j, n;
|
||||
SERIAL_ECHOPGM(" ");
|
||||
delay(2);
|
||||
}
|
||||
|
||||
SERIAL_ECHO("|"); // now show where non 0xE5's are
|
||||
for (i = 0; i < 16; i++) {
|
||||
delay(2);
|
||||
@@ -113,7 +106,6 @@ int i, j, n;
|
||||
SERIAL_ECHOPGM("?");
|
||||
}
|
||||
SERIAL_ECHO("\n");
|
||||
|
||||
ptr += 16;
|
||||
delay(2);
|
||||
}
|
||||
@@ -121,7 +113,6 @@ int i, j, n;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// M100 F requests the code to return the number of free bytes in the memory pool along with
|
||||
// other vital statistics that define the memory pool.
|
||||
@@ -133,9 +124,7 @@ int i, j, n;
|
||||
ptr = (unsigned char*) __brkval;
|
||||
sp = top_of_stack();
|
||||
n = sp - ptr;
|
||||
|
||||
// Scan through the range looking for the biggest block of 0xE5's we can find
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (*(ptr + i) == (unsigned char) 0xe5) {
|
||||
j = how_many_E5s_are_here((unsigned char*) ptr + i);
|
||||
@@ -155,7 +144,6 @@ int i, j, n;
|
||||
}
|
||||
if (block_cnt > 1)
|
||||
SERIAL_ECHOLNPGM("\nMemory Corruption detected in free memory area.\n");
|
||||
|
||||
SERIAL_ECHO("\nDone.\n");
|
||||
return;
|
||||
}
|
||||
@@ -171,11 +159,9 @@ int i, j, n;
|
||||
ptr = (unsigned char*) __brkval;
|
||||
SERIAL_ECHOPAIR("\n__brkval : ", (long) ptr);
|
||||
ptr += 8;
|
||||
|
||||
sp = top_of_stack();
|
||||
SERIAL_ECHOPAIR("\nStack Pointer : ", (long) sp);
|
||||
SERIAL_ECHOLNPGM("\n");
|
||||
|
||||
n = sp - ptr - 64; // -64 just to keep us from finding interrupt activity that
|
||||
// has altered the stack.
|
||||
j = n / (x + 1);
|
||||
@@ -188,7 +174,6 @@ int i, j, n;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// M100 I Initializes the free memory pool so it can be watched and prints vital
|
||||
// statistics that define the free memory pool.
|
||||
@@ -198,20 +183,15 @@ int i, j, n;
|
||||
ptr = (unsigned char*) __brkval; // Repeated M100 with no sub-command will not destroy the
|
||||
SERIAL_ECHOPAIR("\n__brkval : ", (long) ptr); // state of the initialized free memory pool.
|
||||
ptr += 8;
|
||||
|
||||
sp = top_of_stack();
|
||||
SERIAL_ECHOPAIR("\nStack Pointer : ", (long) sp);
|
||||
SERIAL_ECHOLNPGM("\n");
|
||||
|
||||
n = sp - ptr - 64; // -64 just to keep us from finding interrupt activity that
|
||||
// has altered the stack.
|
||||
|
||||
SERIAL_ECHO(n);
|
||||
SERIAL_ECHOLNPGM(" bytes of memory initialized.\n");
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
*(ptr + i) = (unsigned char) 0xe5;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (*(ptr + i) != (unsigned char) 0xe5) {
|
||||
SERIAL_ECHOPAIR("? address : ", (unsigned long) ptr + i);
|
||||
@@ -238,8 +218,7 @@ unsigned char *top_of_stack() {
|
||||
// 3 support routines to print hex numbers. We can print a nibble, byte and word
|
||||
//
|
||||
|
||||
void prt_hex_nibble( unsigned int n )
|
||||
{
|
||||
void prt_hex_nibble(unsigned int n) {
|
||||
if (n <= 9)
|
||||
SERIAL_ECHO(n);
|
||||
else
|
||||
@@ -247,14 +226,12 @@ void prt_hex_nibble( unsigned int n )
|
||||
delay(2);
|
||||
}
|
||||
|
||||
void prt_hex_byte(unsigned int b)
|
||||
{
|
||||
void prt_hex_byte(unsigned int b) {
|
||||
prt_hex_nibble((b & 0xf0) >> 4);
|
||||
prt_hex_nibble(b & 0x0f);
|
||||
}
|
||||
|
||||
void prt_hex_word(unsigned int w)
|
||||
{
|
||||
void prt_hex_word(unsigned int w) {
|
||||
prt_hex_byte((w & 0xff00) >> 8);
|
||||
prt_hex_byte(w & 0x0ff);
|
||||
}
|
||||
@@ -262,10 +239,8 @@ void prt_hex_word(unsigned int w)
|
||||
// how_many_E5s_are_here() is a utility function to easily find out how many 0xE5's are
|
||||
// at the specified location. Having this logic as a function simplifies the search code.
|
||||
//
|
||||
int how_many_E5s_are_here( unsigned char *p)
|
||||
{
|
||||
int how_many_E5s_are_here(unsigned char* p) {
|
||||
int n;
|
||||
|
||||
for (n = 0; n < 32000; n++) {
|
||||
if (*(p + n) != (unsigned char) 0xe5)
|
||||
return n - 1;
|
||||
|
Reference in New Issue
Block a user