Código: Seleccionar todo
// #############################################################################
// ┏┻┻┻┻┻┻┓
// ┫ ┣ VaDeRetro
// ┫ ┣ RAM
// ┫ ┣ Tester
// ┗┳┳┳┳┳┳┛
// ATMega device signature & fuse checker
//
// #############################################################################
#define SIGSIZE 32 // Signature address space size
#define HEXBYTEBUFFER 4 // Buffer for hex byte
#define SIGBUFFER 10 // Buffer for full device signature
#undef SHOW_CHAR_MAP 214 // Show character map from this character code
#include <avr/boot.h>
void setup()
{
byte
b, // Last byte
bAddress = 0, // Address
bIX = 0; // Index counter
char
cByte[HEXBYTEBUFFER], // Hex byte buffer
cSignature[SIGBUFFER], // Device signature buffer
*cSig = cSignature - HEXBYTEBUFFER + 1, // Device signature pointer
*cFuseName[]= // Fuse names
{
"Low", "Lock", "Extended", "High"
};
Serial.begin( 115200 ); // Serial port init
// Show signature bytes
Serial.println();
Serial.print( "Boot signature:\t" );
while ( bAddress < SIGSIZE )
{
b = boot_signature_byte_get( bAddress );
if ( b == 255 ) bIX++;
snprintf( cByte, HEXBYTEBUFFER, "%02X ", b );
if ( bAddress < 6 && ! ( bAddress & 1 ) )
strcpy( cSig += HEXBYTEBUFFER - 1, cByte );
Serial.print( cByte );
if ( ! ( ++bAddress & 15 ) && ( bAddress & 16 ) )
Serial.print( "\n\t\t" );
}
// Show device signature (hex & binary)
Serial.print( "\nSignature:\t" );
Serial.println( cSignature );
// Show fuses reads
for ( bAddress = 0; bAddress < 4; bAddress++ )
{
b = boot_lock_fuse_bits_get( bAddress );
snprintf( cByte, 3, "%02Xd ", b );
Serial.print( cFuseName[ bAddress ] );
Serial.print( " fuse:\t" );
Serial.print( cByte );
Serial.print( ' ' );
Serial.print( b, BIN );
Serial.println( "b" );
}
// Show index
Serial.print( "Index:\t\t" );
Serial.println( (float)100*bIX/SIGSIZE, 2 );
}
void loop()
{
}