Compare commits
No commits in common. "2ca894189969dac87bed71fb5e138110fabf8a3b" and "10111979a869405591c1082d6e64113a305491d9" have entirely different histories.
2ca8941899
...
10111979a8
17
README.md
17
README.md
|
|
@ -5,23 +5,6 @@ Programming tool for parallel EEPROM chips, based on a ATmega16.
|
||||||
Only supports AT28C256 EEPROM chips as of now.
|
Only supports AT28C256 EEPROM chips as of now.
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
### Using the python tool
|
|
||||||
|
|
||||||
(TODO)
|
|
||||||
|
|
||||||
|
|
||||||
### Using the serial terminal
|
|
||||||
|
|
||||||
The device uses a baud-rate of 38.4 kbps.
|
|
||||||
Output lines end with a line feed (LF), input lines may end with LF or CR+LF.
|
|
||||||
|
|
||||||
Example for using `picocom` to access the device:
|
|
||||||
|
|
||||||
picocom -b 38400 --imap lfcrlf --echo /dev/ttyUSB0
|
|
||||||
|
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
### VS Code configuration
|
### VS Code configuration
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
# Compiler and tools
|
# Compiler and tools
|
||||||
CC = avr-gcc
|
CC = avr-gcc
|
||||||
OBJCOPY = avr-objcopy
|
OBJCOPY = avr-objcopy
|
||||||
AVRDUDE ?= avrdude
|
AVRDUDE = avrdude
|
||||||
|
|
||||||
# Compiler and linker flags
|
# Compiler and linker flags
|
||||||
CFLAGS = -Wall -std=c11 -Os
|
CFLAGS = -Wall -std=c11 -Os
|
||||||
|
|
|
||||||
|
|
@ -10,22 +10,12 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
|
||||||
// Internal function prototypes
|
|
||||||
void _uartPutAsciiBlock(DataBuffer buffer);
|
|
||||||
|
|
||||||
// Mode: ASCII (false) or binary (true)
|
|
||||||
bool binary_mode = false;
|
|
||||||
|
|
||||||
// Execute a single parsed command
|
// Execute a single parsed command
|
||||||
void executeCommand(CommandLine cmdLine) {
|
void executeCommand(CommandLine cmdLine) {
|
||||||
// Parse command
|
// Parse command
|
||||||
if (strcmp(cmdLine.command, "INIT") == 0) {
|
if (strcmp(cmdLine.command, "INIT") == 0) {
|
||||||
// INIT command: Initializes connection.
|
// INIT command: Initializes connection.
|
||||||
commandInit(cmdLine.arg);
|
commandInit();
|
||||||
}
|
|
||||||
else if (strcmp(cmdLine.command, "HELP") == 0) {
|
|
||||||
// HELP command: Print a list of supported commands.
|
|
||||||
commandHelp(cmdLine.arg);
|
|
||||||
}
|
}
|
||||||
else if (strcmp(cmdLine.command, "READ") == 0) {
|
else if (strcmp(cmdLine.command, "READ") == 0) {
|
||||||
// READ command: Takes a hex address range (or single address) as argument,
|
// READ command: Takes a hex address range (or single address) as argument,
|
||||||
|
|
@ -50,40 +40,8 @@ void executeCommand(CommandLine cmdLine) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void commandInit(char* arg) {
|
void commandInit() {
|
||||||
// (Re-)initialize EEPROM functions
|
// TODO init... or something?
|
||||||
eepromInit();
|
|
||||||
|
|
||||||
// Default mode: ASCII
|
|
||||||
binary_mode = false;
|
|
||||||
|
|
||||||
if (arg != NULL) {
|
|
||||||
if (strcmp(arg, "BINARY") == 0) {
|
|
||||||
binary_mode = true;
|
|
||||||
} else if (strcmp(arg, "ASCII") == 0 || strcmp(arg, "TEXT") == 0) {
|
|
||||||
binary_mode = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (binary_mode) {
|
|
||||||
uartPutLine("OK (binary mode)");
|
|
||||||
} else {
|
|
||||||
uartPutLine("OK (ASCII mode)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void commandHelp() {
|
|
||||||
uartPutLine("HELP - Supported commands:");
|
|
||||||
uartPutLine("HELP - HELP");
|
|
||||||
uartPutLine("HELP - INIT [BINARY|ASCII]");
|
|
||||||
uartPutLine("HELP - READ 0000:0FFF");
|
|
||||||
uartPutLine("HELP - WRITE 0000");
|
|
||||||
uartPutLine("HELP - ERASE 0000:0FFF");
|
|
||||||
|
|
||||||
// TODO remove those
|
|
||||||
uartPutLine("HELP - TESTREAD (only for testing)");
|
|
||||||
uartPutLine("HELP - TESTWRITE (only for testing)");
|
|
||||||
|
|
||||||
uartPutLine("OK");
|
uartPutLine("OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,35 +71,22 @@ void commandRead(char* arg) {
|
||||||
// Read a single block with up to DATA_BLOCK_SIZE bytes
|
// Read a single block with up to DATA_BLOCK_SIZE bytes
|
||||||
range.from = eepromReadBlock(range, &buffer);
|
range.from = eepromReadBlock(range, &buffer);
|
||||||
|
|
||||||
if (binary_mode) {
|
// TODO binary output
|
||||||
// Send block as binary "package":
|
|
||||||
// First the size of the package (1 byte) followed by the data bytes
|
|
||||||
uartPutChar(buffer.bytes);
|
|
||||||
|
|
||||||
for (int i = 0; i < buffer.bytes; i++) {
|
// ASCII output
|
||||||
uartPutChar(buffer.data[i]);
|
char outBuffer[20];
|
||||||
}
|
sprintf(outBuffer, "<%d>", buffer.bytes);
|
||||||
} else {
|
uartPutString(outBuffer);
|
||||||
// Fancy ASCII output
|
|
||||||
_uartPutAsciiBlock(buffer);
|
for (int i = 0; i < buffer.bytes; i++) {
|
||||||
|
sprintf(outBuffer, " %02X", buffer.data[i]);
|
||||||
|
uartPutString(outBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uartPutLine(NULL);
|
||||||
} while (buffer.bytes > 0);
|
} while (buffer.bytes > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _uartPutAsciiBlock(DataBuffer buffer) {
|
|
||||||
char outBuffer[20];
|
|
||||||
sprintf(outBuffer, "<%d>", buffer.bytes);
|
|
||||||
uartPutString(outBuffer);
|
|
||||||
|
|
||||||
for (int i = 0; i < buffer.bytes; i++) {
|
|
||||||
sprintf(outBuffer, " %02X", buffer.data[i]);
|
|
||||||
uartPutString(outBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
uartPutLine(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void commandWrite(char* arg) {
|
void commandWrite(char* arg) {
|
||||||
if (arg == NULL) {
|
if (arg == NULL) {
|
||||||
uartPutLine("ERR WRITE needs a start address");
|
uartPutLine("ERR WRITE needs a start address");
|
||||||
|
|
@ -155,12 +100,6 @@ void commandWrite(char* arg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only binary mode
|
|
||||||
if (!binary_mode) {
|
|
||||||
uartPutLine("ERR WRITE in ASCII mode is not implemented");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO read data from input and write to EEPROM
|
// TODO read data from input and write to EEPROM
|
||||||
uartPutLine("ERR not implemented");
|
uartPutLine("ERR not implemented");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set UART Baud rate
|
// Set UART Baud rate
|
||||||
#define BAUD 38400UL
|
#define BAUD 9600UL
|
||||||
|
|
||||||
#endif /* CONFIG_H_ */
|
#endif /* CONFIG_H_ */
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ int main(void) {
|
||||||
_delay_ms(100);
|
_delay_ms(100);
|
||||||
|
|
||||||
// Write initial message via UART
|
// Write initial message via UART
|
||||||
uartPutLine("INFO - EEPROM programmer by binaryDiv");
|
uartPutLine("INFO -- EEPROM programmer by binaryDiv");
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
// Run main loop endlessly
|
// Run main loop endlessly
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue