|
@@ -1,33 +1,12 @@
|
|
|
#include "Dcodes.h"
|
|
|
-#include "Marlin.h"
|
|
|
-
|
|
|
-#ifdef DEBUG_DCODES
|
|
|
-
|
|
|
-#include "ConfigurationStore.h"
|
|
|
+//#include "Marlin.h"
|
|
|
+#include "language.h"
|
|
|
#include "cmdqueue.h"
|
|
|
-#include "pat9125.h"
|
|
|
-#include "adc.h"
|
|
|
-#include "temperature.h"
|
|
|
-#include <avr/wdt.h>
|
|
|
+#include <stdio.h>
|
|
|
+#include <avr/pgmspace.h>
|
|
|
|
|
|
|
|
|
-#define FLASHSIZE 0x40000
|
|
|
-
|
|
|
-#define RAMSIZE 0x2000
|
|
|
-#define boot_src_addr (*((uint32_t*)(RAMSIZE - 16)))
|
|
|
-#define boot_dst_addr (*((uint32_t*)(RAMSIZE - 12)))
|
|
|
-#define boot_copy_size (*((uint16_t*)(RAMSIZE - 8)))
|
|
|
-#define boot_reserved (*((uint8_t*)(RAMSIZE - 6)))
|
|
|
-#define boot_app_flags (*((uint8_t*)(RAMSIZE - 5)))
|
|
|
-#define boot_app_magic (*((uint32_t*)(RAMSIZE - 4)))
|
|
|
-#define BOOT_APP_FLG_ERASE 0x01
|
|
|
-#define BOOT_APP_FLG_COPY 0x02
|
|
|
-#define BOOT_APP_FLG_FLASH 0x04
|
|
|
-
|
|
|
-extern uint8_t fsensor_log;
|
|
|
-extern float current_temperature_pinda;
|
|
|
-extern float axis_steps_per_unit[NUM_AXIS];
|
|
|
-
|
|
|
+#define DBG(args...) printf_P(args)
|
|
|
|
|
|
inline void print_hex_nibble(uint8_t val)
|
|
|
{
|
|
@@ -46,26 +25,18 @@ void print_hex_word(uint16_t val)
|
|
|
print_hex_byte(val & 255);
|
|
|
}
|
|
|
|
|
|
-void print_mem(uint32_t address, uint16_t count, uint8_t type, uint8_t countperline = 16)
|
|
|
+void print_eeprom(uint16_t address, uint16_t count, uint8_t countperline = 16)
|
|
|
{
|
|
|
while (count)
|
|
|
{
|
|
|
- if (type == 2)
|
|
|
- print_hex_nibble(address >> 16);
|
|
|
print_hex_word(address);
|
|
|
putchar(' ');
|
|
|
uint8_t count_line = countperline;
|
|
|
while (count && count_line)
|
|
|
{
|
|
|
uint8_t data = 0;
|
|
|
- switch (type)
|
|
|
- {
|
|
|
- case 0: data = *((uint8_t*)address++); break;
|
|
|
- case 1: data = eeprom_read_byte((uint8_t*)address++); break;
|
|
|
- case 2: data = pgm_read_byte_far((uint8_t*)address++); break;
|
|
|
- }
|
|
|
putchar(' ');
|
|
|
- print_hex_byte(data);
|
|
|
+ print_hex_byte(eeprom_read_byte((uint8_t*)address++));
|
|
|
count_line--;
|
|
|
count--;
|
|
|
}
|
|
@@ -73,9 +44,6 @@ void print_mem(uint32_t address, uint16_t count, uint8_t type, uint8_t countperl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//#define LOG(args...) printf(args)
|
|
|
-#define LOG(args...)
|
|
|
-
|
|
|
int parse_hex(char* hex, uint8_t* data, int count)
|
|
|
{
|
|
|
int parsed = 0;
|
|
@@ -99,6 +67,112 @@ int parse_hex(char* hex, uint8_t* data, int count)
|
|
|
return parsed;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+void print_mem(uint32_t address, uint16_t count, uint8_t type, uint8_t countperline = 16)
|
|
|
+{
|
|
|
+ while (count)
|
|
|
+ {
|
|
|
+ if (type == 2)
|
|
|
+ print_hex_nibble(address >> 16);
|
|
|
+ print_hex_word(address);
|
|
|
+ putchar(' ');
|
|
|
+ uint8_t count_line = countperline;
|
|
|
+ while (count && count_line)
|
|
|
+ {
|
|
|
+ uint8_t data = 0;
|
|
|
+ switch (type)
|
|
|
+ {
|
|
|
+ case 0: data = *((uint8_t*)address++); break;
|
|
|
+ case 1: data = eeprom_read_byte((uint8_t*)address++); break;
|
|
|
+ case 2: data = pgm_read_byte_far((uint8_t*)address++); break;
|
|
|
+ }
|
|
|
+ putchar(' ');
|
|
|
+ print_hex_byte(data);
|
|
|
+ count_line--;
|
|
|
+ count--;
|
|
|
+ }
|
|
|
+ putchar('\n');
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#ifdef DEBUG_DCODE3
|
|
|
+#define EEPROM_SIZE 0x1000
|
|
|
+void dcode_3()
|
|
|
+{
|
|
|
+ DBG(_N("D3 - Read/Write EEPROM\n"));
|
|
|
+ uint16_t address = 0x0000; //default 0x0000
|
|
|
+ uint16_t count = EEPROM_SIZE; //default 0x1000 (entire eeprom)
|
|
|
+ if (code_seen('A')) // Address (0x0000-0x0fff)
|
|
|
+ address = (strchr_pointer[1] == 'x')?strtol(strchr_pointer + 2, 0, 16):(int)code_value();
|
|
|
+ if (code_seen('C')) // Count (0x0001-0x1000)
|
|
|
+ count = (int)code_value();
|
|
|
+ address &= 0x1fff;
|
|
|
+ if (count > EEPROM_SIZE) count = EEPROM_SIZE;
|
|
|
+ if ((address + count) > EEPROM_SIZE) count = EEPROM_SIZE - address;
|
|
|
+ if (code_seen('X')) // Data
|
|
|
+ {
|
|
|
+ uint8_t data[16];
|
|
|
+ count = parse_hex(strchr_pointer + 1, data, 16);
|
|
|
+ if (count > 0)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < count; i++)
|
|
|
+ eeprom_write_byte((uint8_t*)(address + i), data[i]);
|
|
|
+ printf_P(_N("%d bytes written to EEPROM at address 0x%04x"), count, address);
|
|
|
+ putchar('\n');
|
|
|
+ }
|
|
|
+ else
|
|
|
+ count = 0;
|
|
|
+ }
|
|
|
+ print_mem(address, count, 1);
|
|
|
+/* while (count)
|
|
|
+ {
|
|
|
+ print_hex_word(address);
|
|
|
+ putchar(' ');
|
|
|
+ uint8_t countperline = 16;
|
|
|
+ while (count && countperline)
|
|
|
+ {
|
|
|
+ uint8_t data = eeprom_read_byte((uint8_t*)address++);
|
|
|
+ putchar(' ');
|
|
|
+ print_hex_byte(data);
|
|
|
+ countperline--;
|
|
|
+ count--;
|
|
|
+ }
|
|
|
+ putchar('\n');
|
|
|
+ }*/
|
|
|
+}
|
|
|
+#endif //DEBUG_DCODE3
|
|
|
+
|
|
|
+#ifdef DEBUG_DCODES
|
|
|
+
|
|
|
+#include "ConfigurationStore.h"
|
|
|
+#include "cmdqueue.h"
|
|
|
+#include "pat9125.h"
|
|
|
+#include "adc.h"
|
|
|
+#include "temperature.h"
|
|
|
+#include <avr/wdt.h>
|
|
|
+
|
|
|
+
|
|
|
+#define FLASHSIZE 0x40000
|
|
|
+
|
|
|
+#define RAMSIZE 0x2000
|
|
|
+#define boot_src_addr (*((uint32_t*)(RAMSIZE - 16)))
|
|
|
+#define boot_dst_addr (*((uint32_t*)(RAMSIZE - 12)))
|
|
|
+#define boot_copy_size (*((uint16_t*)(RAMSIZE - 8)))
|
|
|
+#define boot_reserved (*((uint8_t*)(RAMSIZE - 6)))
|
|
|
+#define boot_app_flags (*((uint8_t*)(RAMSIZE - 5)))
|
|
|
+#define boot_app_magic (*((uint32_t*)(RAMSIZE - 4)))
|
|
|
+#define BOOT_APP_FLG_ERASE 0x01
|
|
|
+#define BOOT_APP_FLG_COPY 0x02
|
|
|
+#define BOOT_APP_FLG_FLASH 0x04
|
|
|
+
|
|
|
+extern uint8_t fsensor_log;
|
|
|
+extern float current_temperature_pinda;
|
|
|
+extern float axis_steps_per_unit[NUM_AXIS];
|
|
|
+
|
|
|
+
|
|
|
+//#define LOG(args...) printf(args)
|
|
|
+#define LOG(args...)
|
|
|
+
|
|
|
void dcode__1()
|
|
|
{
|
|
|
printf("D-1 - Endless loop\n");
|
|
@@ -177,52 +251,6 @@ void dcode_2()
|
|
|
}*/
|
|
|
}
|
|
|
|
|
|
-void dcode_3()
|
|
|
-{
|
|
|
- LOG("D3 - Read/Write EEPROM\n");
|
|
|
- uint16_t address = 0x0000; //default 0x0000
|
|
|
- uint16_t count = 0x2000; //default 0x2000 (entire eeprom)
|
|
|
- if (code_seen('A')) // Address (0x0000-0x1fff)
|
|
|
- address = (strchr_pointer[1] == 'x')?strtol(strchr_pointer + 2, 0, 16):(int)code_value();
|
|
|
- if (code_seen('C')) // Count (0x0001-0x2000)
|
|
|
- count = (int)code_value();
|
|
|
- address &= 0x1fff;
|
|
|
- if (count > 0x2000) count = 0x2000;
|
|
|
- if ((address + count) > 0x2000) count = 0x2000 - address;
|
|
|
- if (code_seen('X')) // Data
|
|
|
- {
|
|
|
- uint8_t data[16];
|
|
|
- count = parse_hex(strchr_pointer + 1, data, 16);
|
|
|
- if (count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < count; i++)
|
|
|
- eeprom_write_byte((uint8_t*)(address + i), data[i]);
|
|
|
- LOG(count, DEC);
|
|
|
- LOG(" bytes written to EEPROM at address ");
|
|
|
- print_hex_word(address);
|
|
|
- putchar('\n');
|
|
|
- }
|
|
|
- else
|
|
|
- count = 0;
|
|
|
- }
|
|
|
- print_mem(address, count, 1);
|
|
|
-/* while (count)
|
|
|
- {
|
|
|
- print_hex_word(address);
|
|
|
- putchar(' ');
|
|
|
- uint8_t countperline = 16;
|
|
|
- while (count && countperline)
|
|
|
- {
|
|
|
- uint8_t data = eeprom_read_byte((uint8_t*)address++);
|
|
|
- putchar(' ');
|
|
|
- print_hex_byte(data);
|
|
|
- countperline--;
|
|
|
- count--;
|
|
|
- }
|
|
|
- putchar('\n');
|
|
|
- }*/
|
|
|
-}
|
|
|
-
|
|
|
void dcode_4()
|
|
|
{
|
|
|
LOG("D4 - Read/Write PIN\n");
|