|  |  | @ -78,7 +78,7 @@ char* top_of_stack() { | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | // Count the number of test bytes at the specified location.
 |  |  |  | // Count the number of test bytes at the specified location.
 | 
			
		
	
		
		
			
				
					
					|  |  |  | int16_t count_test_bytes(const uint8_t * const ptr) { |  |  |  | int16_t count_test_bytes(const char * const ptr) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   for (uint16_t i = 0; i < 32000; i++) |  |  |  |   for (uint16_t i = 0; i < 32000; i++) | 
			
		
	
		
		
			
				
					
					|  |  |  |     if (((char) ptr[i]) != TEST_BYTE) |  |  |  |     if (((char) ptr[i]) != TEST_BYTE) | 
			
		
	
		
		
			
				
					
					|  |  |  |       return i - 1; |  |  |  |       return i - 1; | 
			
		
	
	
		
		
			
				
					|  |  | @ -100,13 +100,13 @@ int16_t count_test_bytes(const uint8_t * const ptr) { | 
			
		
	
		
		
			
				
					
					|  |  |  |    *  the block. If so, it may indicate memory corruption due to a bad pointer. |  |  |  |    *  the block. If so, it may indicate memory corruption due to a bad pointer. | 
			
		
	
		
		
			
				
					
					|  |  |  |    *  Unexpected bytes are flagged in the right column. |  |  |  |    *  Unexpected bytes are flagged in the right column. | 
			
		
	
		
		
			
				
					
					|  |  |  |    */ |  |  |  |    */ | 
			
		
	
		
		
			
				
					
					|  |  |  |   void dump_free_memory(const uint8_t *ptr, const uint8_t *sp) { |  |  |  |   void dump_free_memory(const char *ptr, const char *sp) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     //
 |  |  |  |     //
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     // Start and end the dump on a nice 16 byte boundary
 |  |  |  |     // Start and end the dump on a nice 16 byte boundary
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     // (even though the values are not 16-byte aligned).
 |  |  |  |     // (even though the values are not 16-byte aligned).
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     //
 |  |  |  |     //
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     ptr = (uint8_t *)((uint16_t)ptr & 0xFFF0); // Align to 16-byte boundary
 |  |  |  |     ptr = (char *)((uint16_t)ptr & 0xFFF0); // Align to 16-byte boundary
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     sp  = (uint8_t *)((uint16_t)sp  | 0x000F); // Align sp to the 15th byte (at or above sp)
 |  |  |  |     sp  = (char *)((uint16_t)sp  | 0x000F); // Align sp to the 15th byte (at or above sp)
 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     // Dump command main loop
 |  |  |  |     // Dump command main loop
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     while (ptr < sp) { |  |  |  |     while (ptr < sp) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -121,7 +121,7 @@ int16_t count_test_bytes(const uint8_t * const ptr) { | 
			
		
	
		
		
			
				
					
					|  |  |  |       SERIAL_CHAR('|');                   // Point out non test bytes
 |  |  |  |       SERIAL_CHAR('|');                   // Point out non test bytes
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       for (uint8_t i = 0; i < 16; i++) { |  |  |  |       for (uint8_t i = 0; i < 16; i++) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         char ccc = (char)ptr[i]; // cast to char before automatically casting to char on assignment, in case the compiler is broken
 |  |  |  |         char ccc = (char)ptr[i]; // cast to char before automatically casting to char on assignment, in case the compiler is broken
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (&ptr[i] >= command_queue && &ptr[i] < &command_queue[BUFSIZE][MAX_CMD_SIZE]) { // Print out ASCII in the command buffer area
 |  |  |  |         if (&ptr[i] >= (const char*)command_queue && &ptr[i] < (const char*)(command_queue + sizeof(command_queue))) { // Print out ASCII in the command buffer area
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |           if (!WITHIN(ccc, ' ', 0x7E)) ccc = ' '; |  |  |  |           if (!WITHIN(ccc, ' ', 0x7E)) ccc = ' '; | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         else { // If not in the command buffer area, flag bytes that don't match the test byte
 |  |  |  |         else { // If not in the command buffer area, flag bytes that don't match the test byte
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -153,13 +153,13 @@ void M100_dump_routine(const char * const title, const char *start, const char * | 
			
		
	
		
		
			
				
					
					|  |  |  |  *  Return the number of free bytes in the memory pool, |  |  |  |  *  Return the number of free bytes in the memory pool, | 
			
		
	
		
		
			
				
					
					|  |  |  |  *  with other vital statistics defining the pool. |  |  |  |  *  with other vital statistics defining the pool. | 
			
		
	
		
		
			
				
					
					|  |  |  |  */ |  |  |  |  */ | 
			
		
	
		
		
			
				
					
					|  |  |  | void free_memory_pool_report(const char * const ptr, const uint16_t size) { |  |  |  | void free_memory_pool_report(char * const ptr, const uint16_t size) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   int16_t max_cnt = -1; |  |  |  |   int16_t max_cnt = -1; | 
			
		
	
		
		
			
				
					
					|  |  |  |   uint16_t block_cnt = 0; |  |  |  |   uint16_t block_cnt = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |   char *max_addr = NULL; |  |  |  |   char *max_addr = NULL; | 
			
		
	
		
		
			
				
					
					|  |  |  |   // Find the longest block of test bytes in the buffer
 |  |  |  |   // Find the longest block of test bytes in the buffer
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   for (uint16_t i = 0; i < size; i++) { |  |  |  |   for (uint16_t i = 0; i < size; i++) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     char * const addr = ptr + i; |  |  |  |     char *addr = ptr + i; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     if (*addr == TEST_BYTE) { |  |  |  |     if (*addr == TEST_BYTE) { | 
			
		
	
		
		
			
				
					
					|  |  |  |       const uint16_t j = count_test_bytes(addr); |  |  |  |       const uint16_t j = count_test_bytes(addr); | 
			
		
	
		
		
			
				
					
					|  |  |  |       if (j > 8) { |  |  |  |       if (j > 8) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -209,7 +209,7 @@ void free_memory_pool_report(const char * const ptr, const uint16_t size) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  * M100 I |  |  |  |  * M100 I | 
			
		
	
		
		
			
				
					
					|  |  |  |  *  Init memory for the M100 tests. (Automatically applied on the first M100.) |  |  |  |  *  Init memory for the M100 tests. (Automatically applied on the first M100.) | 
			
		
	
		
		
			
				
					
					|  |  |  |  */ |  |  |  |  */ | 
			
		
	
		
		
			
				
					
					|  |  |  | void init_free_memory(uint8_t *ptr, int16_t size) { |  |  |  | void init_free_memory(char *ptr, int16_t size) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   SERIAL_ECHOLNPGM("Initializing free memory block.\n\n"); |  |  |  |   SERIAL_ECHOLNPGM("Initializing free memory block.\n\n"); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   size -= 250;    // -250 to avoid interrupt activity that's altered the stack.
 |  |  |  |   size -= 250;    // -250 to avoid interrupt activity that's altered the stack.
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -292,7 +292,7 @@ int check_for_free_memory_corruption(const char * const title) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     //   idle();
 |  |  |  |     //   idle();
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     safe_delay(20); |  |  |  |     safe_delay(20); | 
			
		
	
		
		
			
				
					
					|  |  |  |     #ifdef M100_FREE_MEMORY_DUMPER |  |  |  |     #ifdef M100_FREE_MEMORY_DUMPER | 
			
		
	
		
		
			
				
					
					|  |  |  |       M100_dump_routine("   Memory corruption detected with sp<Heap\n", (char*)0x1B80, 0x21FF); |  |  |  |       M100_dump_routine("   Memory corruption detected with sp<Heap\n", (char*)0x1B80, (char*)0x21FF); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     #endif |  |  |  |     #endif | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |