March Madness - Arduino Explorer |
In continuation of my theme of investigating the properites of the Arduino.
This program combines some of my previous programs, FLASH dump, the EPROM dump, SHOW PINS and it adds RAM dump, and I2C scan.
This is presented in a single character command line style interface similar to the BIOS of early 8 bit systems of the late 70's and early 80's (where I got my start in computers)
Arduino>? 0=Zero address counters ?=Help E=Dump EEPROM F=Dump FLASH R=Dump RAM I=I2C scan S=Show pins Arduino> Arduino>I starting scanning of I2C bus from 1 to 127... addr:1 addr:2 addr:3 addr:4 addr:5 addr:6 addr:7 addr:8 addr:9 addr:10 addr:11 addr:12 addr:13 addr:14 addr:15 addr:16 addr:17 addr:18 addr:19 addr:20 addr:21 addr:22 addr:23 addr:24 addr:25 addr:26 addr:27 addr:28 addr:29 addr:30 addr:31 addr:32 addr:33 addr:34 addr:35 addr:36 addr:37 addr:38 addr:39 addr:40 addr:41 addr:42 addr:43 addr:44 addr:45 addr:46 addr:47 addr:48 addr:49 addr:50 addr:51 addr:52 addr:53 addr:54 addr:55 addr:56 addr:57 addr:58 addr:59 addr:60 addr:61 addr:62 addr:63 addr:64 addr:65 addr:66 addr:67 addr:68 addr:69 addr:70 addr:71 addr:72 addr:73 addr:74 addr:75 addr:76 addr:77 found! addr:78 addr:79 addr:80 addr:81 addr:82 addr:83 addr:84 addr:85 addr:86 addr:87 addr:88 addr:89 addr:90 addr:91 addr:92 addr:93 addr:94 addr:95 addr:96 addr:97 addr:98 addr:99 addr:100 addr:101 addr:102 addr:103 addr:104 addr:105 addr:106 addr:107 addr:108 addr:109 addr:110 addr:111 addr:112 addr:113 addr:114 addr:115 addr:116 addr:117 addr:118 addr:119 addr:120 addr:121 addr:122 addr:123 addr:124 addr:125 addr:126 addr:127 I2C device count = 1 Arduino> Arduino>F 0000 - 0C 94 63 00 0C 94 8B 00 0C 94 8B 00 0C 94 8B 00 ..c............. 0010 - 0C 94 8B 00 0C 94 8B 00 0C 94 8B 00 0C 94 8B 00 ................ 0020 - 0C 94 8B 00 0C 94 8B 00 0C 94 8B 00 0C 94 8B 00 ................ 0030 - 0C 94 8B 00 0C 94 8B 00 0C 94 8B 00 0C 94 8B 00 ................ 0040 - 0C 94 15 0D 0C 94 8B 00 0C 94 BB 09 0C 94 8B 00 ................ 0050 - 0C 94 8B 00 0C 94 8B 00 0C 94 8B 00 0C 94 8B 00 ................ 0060 - 0C 94 BF 04 0C 94 8B 00 00 00 00 00 24 00 27 00 ............$.'. 0070 - 2A 00 00 00 00 00 25 00 28 00 2B 00 00 00 00 00 *.....%.(.+..... 0080 - 23 00 26 00 29 00 04 04 04 04 04 04 04 04 02 02 #.&.)........... 0090 - 02 02 02 02 03 03 03 03 03 03 01 02 04 08 10 20 ............... 00A0 - 40 80 01 02 04 08 10 20 01 02 04 08 10 20 00 00 @...... ..... .. 00B0 - 00 07 00 02 01 00 00 03 04 06 00 00 00 00 00 00 ................ 00C0 - 00 00 5A 04 40 0B 11 24 1F BE CF EF D8 E0 DE BF ..Z.@..$........ 00D0 - CD BF 12 E0 A0 E0 B1 E0 E2 EB FC E1 02 C0 05 90 ................ 00E0 - 0D 92 A8 30 B1 07 D9 F7 13 E0 A8 E0 B2 E0 01 C0 ...0............ 00F0 - 1D 92 A0 3D B1 07 E1 F7 10 E0 C6 EC D0 E0 04 C0 ...=............ Arduino> Arduino>R 0000 - C6 00 BC 08 00 00 00 00 08 00 00 00 00 00 0E 00 ................ 0010 - 00 00 05 00 30 08 00 08 E8 00 CC 02 BB 08 1E 00 ....0........... 0020 - 60 60 60 00 00 00 30 00 30 01 00 01 00 00 00 60 ```...0.0......` 0030 - 60 60 60 60 60 06 07 07 60 60 60 00 00 00 00 00 `````...```..... 0040 - FF FF 01 00 03 03 B2 00 00 00 00 00 00 00 00 60 ...............` 0050 - 30 FF 60 00 00 00 60 00 60 60 60 00 60 BB 08 82 0.`...`.```.`... 0060 - 00 00 60 60 00 60 AC 60 00 00 60 00 00 00 01 00 ..``.`.`..`..... 0070 - 00 60 60 60 60 60 60 60 00 00 87 00 00 60 00 00 .```````.....`.. 0080 - 01 03 00 60 B8 00 00 00 00 00 00 00 60 60 60 60 ...`........```` 0090 - 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 ```````````````` 00A0 - 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 ```````````````` 00B0 - 01 04 74 00 00 60 00 60 48 F8 FE FE 45 00 60 60 ..t..`.`H...E.`` 00C0 - 40 98 06 60 67 00 66 60 60 60 60 60 60 60 60 60 @..`g.f````````` 00D0 - 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 ```````````````` 00E0 - 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 ```````````````` 00F0 - 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 ```````````````` Arduino> Arduino>S Pin # 2 0 Pin # 3 0 Pin # 4 0 Pin # 5 0 Pin # 6 0 Pin # 7 0 Pin # 8 0 Pin # 9 0 Pin # 10 0 Pin # 11 0 Pin # 12 0 Pin # 13 0 Analog Pin # 0 511 Analog Pin # 1 423 Analog Pin # 2 417 Analog Pin # 3 416 Analog Pin # 4 999 Analog Pin # 5 1001 Arduino> |
|
//************************************************************************ //* Arduino Exploer //* (C) 2010 by Mark Sproul //* Open source as per standard Arduino code //* //* This is done in the old fashion monitor style low level program //* it allows you to look at various aspects of the Arduino environment //* without writting special code. It can be used for debugging new hardware //* //* ? = Help //* 0 = Zero counters //* E = Dump EEPROM //* F = Dump FLASH //* R = Dump RAM //* I = I2C scan //* S = Show pins //************************************************************************ #ifdef __MWERKS__ #include "codewarrior.h" #else #include <avr/pgmspace.h> #include "EEPROM.h" #endif #include "WProgram.h" #include "HardwareSerial.h" #include "Wire.h" extern "C" { #include "utility/twi.h" // from Wire library, so we can do bus scanning //#include "twi.h" // from Wire library, so we can do bus scanning } enum { kDUMP_FLASH = 0, kDUMP_EEPROM, kDUMP_RAM }; unsigned char *gRamPtr = 0; unsigned int gRamIndex = 0; unsigned long gFlashIndex = 0; //* this gets filled with an array from o -> 256 just to prove that we are looking //* at RAM unsigned char gCharArray[256]; //************************************************************************ static void DumpHex(byte dumpWhat, unsigned long startAddress, int numRows) { int ii; int theValue; int lineCount; char textString[16]; char asciiDump[24]; unsigned long myAddressPointer; lineCount = 0; myAddressPointer = startAddress; while (lineCount < numRows) { sprintf(textString, "%04X - ", myAddressPointer); Serial.print(textString); asciiDump[0] = 0; for (ii=0; ii<16; ii++) { switch(dumpWhat) { case kDUMP_FLASH: theValue = pgm_read_byte_near(myAddressPointer); break; case kDUMP_EEPROM: #ifndef __MWERKS__ theValue = EEPROM.read(myAddressPointer); #endif break; case kDUMP_RAM: theValue = gRamPtr[myAddressPointer]; break; } sprintf(textString, "%02X ", theValue); Serial.print(textString); if ((theValue >= 0x20) && (theValue < 0x7f)) { asciiDump[ii % 16] = theValue; } else { asciiDump[ii % 16] = '.'; } myAddressPointer++; } asciiDump[16] = 0; Serial.println(asciiDump); lineCount++; } } //******************************************************************* void ShowPins(void) { short ii; int pinValue; for (ii=2; ii<14; ii++) { pinValue = digitalRead(ii); Serial.print("Pin # "); Serial.print(ii); Serial.print(" "); Serial.print(pinValue); Serial.println(); } Serial.println(); for (ii=0; ii<6; ii++) { pinValue = analogRead(ii); Serial.print("Analog Pin # "); Serial.print(ii); Serial.print(" "); Serial.print(pinValue); Serial.println(); } Serial.println(); } //******************************************************************* void PrintHelp(void) { Serial.println("0=Zero address counters"); Serial.println("?=Help"); Serial.println("E=Dump EEPROM"); Serial.println("F=Dump FLASH"); Serial.println("R=Dump RAM"); Serial.println("I=I2C scan"); Serial.println("S=Show pins"); } //**************************************************************************** //* Scan the I2C bus between addresses from_addr and to_addr. //* On each address, call the callback function with the address and result. //* If result==0, address was found, otherwise, address wasn't found //* (can use result to potentially get other status on the I2C bus, see twi.c) //* Assumes Wire.begin() has already been called //* 2009, Tod E. Kurt, http://todbot.com/blog/ //**************************************************************************** void ScanI2CBus(byte from_addr, byte to_addr) { byte addr; byte rc; byte data; // not used, just an address to feed to twi_writeTo() int foundCount; Serial.print("starting scanning of I2C bus from "); Serial.print(from_addr, DEC); Serial.print(" to "); Serial.print(to_addr ,DEC); Serial.println("..."); data = 0; foundCount = 0; for(addr = from_addr; addr <= to_addr; addr++ ) { Serial.print("addr:"); Serial.print(addr,DEC); rc = twi_writeTo(addr, &data, 0, 1); if (rc == 0) { foundCount++; } Serial.print( (rc==0) ? " found!":" "); Serial.print( (addr%4) ? "\t":"\r\n"); } Serial.println(); Serial.print( "I2C device count = "); Serial.println(foundCount); } //************************************************************************ void setup() { int ii; Serial.begin(9600); Serial.println(); Serial.println("Arduino explorer"); PrintHelp(); for (ii=2; ii<14; ii++) { pinMode(ii, INPUT); } for (ii=0; ii<256; ii++) { gCharArray[ii] = ii; } gFlashIndex = 0; } //************************************************************************ void loop() { char theChar; Serial.print("Arduino>"); while (!Serial.available()) { //* wait } theChar = Serial.read(); if (theChar >= 0x60) { theChar = theChar & 0x5f; //* force upper case } Serial.print(theChar); Serial.println(); switch(theChar) { case '0': gFlashIndex = 0; gRamIndex = 0; break; case '?': PrintHelp(); break; case 'E': DumpHex(kDUMP_EEPROM, 0, 32); break; case 'F': DumpHex(kDUMP_FLASH, gFlashIndex, 16); gFlashIndex += 256; break; case 'I': Wire.begin(); ScanI2CBus(1, 127); break; case 'R': DumpHex(kDUMP_RAM, gRamIndex, 16); gRamIndex += 256; break; case 'S': ShowPins(); break; } } |