WIP: settings to file (eeprom) seems to work
This commit is contained in:
@@ -52,7 +52,9 @@ int grblConstruct(char *configStr)
|
||||
lastConfStr = strdup(configStr);
|
||||
|
||||
// Initialize system upon power-up.
|
||||
serial_init(); // Setup serial baud rate and interrupts
|
||||
//serial_init(); // Setup serial baud rate and interrupts
|
||||
ecmc_init_file(); // create and clear file (simulated eeprom)
|
||||
settings_restore(0b1111); // restore all to defaults
|
||||
settings_init(); // Load Grbl settings from EEPROM
|
||||
stepper_init(); // Configure stepper pins and interrupt timers
|
||||
system_init(); // Configure pinout pins and pin-change interrupt
|
||||
@@ -115,7 +117,7 @@ int grblConstruct(char *configStr)
|
||||
report_init_message();
|
||||
|
||||
// Start Grbl main loop. Processes program inputs and executes them.
|
||||
protocol_main_loop();
|
||||
//protocol_main_loop(); This is for serial interface use.. comment out for now..
|
||||
//}
|
||||
|
||||
return 0; //createSocketCAN(configStr,getEcmcSampleTimeMS());
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#define EEPROM_DUMMY_FILE "./ecmc_grbl_eeprom.txt"
|
||||
#define EEPROM_MEM_SIZE 512
|
||||
#define EEPROM_MEM_SIZE 1024
|
||||
char buffer[EEPROM_MEM_SIZE];
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ char buffer[EEPROM_MEM_SIZE];
|
||||
unsigned char ecmc_mem_to_file();
|
||||
// Init file
|
||||
void ecmc_init_file() {
|
||||
printf("%s:%s:%d EEPROM simulated by file..\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
printf("%s:%s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
memset(&buffer[0],0,EEPROM_MEM_SIZE);
|
||||
ecmc_mem_to_file();
|
||||
}
|
||||
@@ -58,7 +58,7 @@ void ecmc_init_file() {
|
||||
// Read file to buffer[]
|
||||
unsigned char ecmc_file_to_mem()
|
||||
{
|
||||
printf("%s:%s:%d EEPROM simulated by file..\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//printf("%s:%s:%d EEPROM simulated by file..\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
FILE* fh = fopen(EEPROM_DUMMY_FILE, "rd");
|
||||
|
||||
@@ -80,7 +80,7 @@ unsigned char ecmc_file_to_mem()
|
||||
// Write buffer[] to file
|
||||
unsigned char ecmc_mem_to_file()
|
||||
{
|
||||
printf("%s:%s:%d EEPROM simulated by file..\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
// printf("%s:%s:%d EEPROM simulated by file..\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
FILE* fh = fopen(EEPROM_DUMMY_FILE, "w");
|
||||
|
||||
@@ -110,9 +110,9 @@ unsigned char ecmc_mem_to_file()
|
||||
*/
|
||||
unsigned char eeprom_get_char( unsigned int addr )
|
||||
{
|
||||
printf("%s:%s:%d EEPROM simulated by file..\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
ecmc_file_to_mem();
|
||||
//printf("%s:%s:%d addr: %ud, value %d..\n",__FILE__,__FUNCTION__,__LINE__,addr,buffer[addr]);
|
||||
|
||||
return buffer[addr];
|
||||
|
||||
//do {} while( EECR & (1<<EEPE) ); // Wait for completion of previous write.
|
||||
@@ -140,10 +140,10 @@ unsigned char eeprom_get_char( unsigned int addr )
|
||||
*/
|
||||
void eeprom_put_char( unsigned int addr, unsigned char new_value )
|
||||
{
|
||||
printf("%s:%s:%d EEPROM simulated by file..\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
ecmc_file_to_mem();
|
||||
buffer[addr] = new_value;
|
||||
//printf("%s:%s:%d addr: %ud, value %d..\n",__FILE__,__FUNCTION__,__LINE__,addr,new_value);
|
||||
|
||||
ecmc_file_to_mem();
|
||||
buffer[addr] = new_value;
|
||||
ecmc_mem_to_file();
|
||||
|
||||
//char old_value; // Old EEPROM value.
|
||||
@@ -201,7 +201,7 @@ void eeprom_put_char( unsigned int addr, unsigned char new_value )
|
||||
|
||||
|
||||
void memcpy_to_eeprom_with_checksum(unsigned int destination, char *source, unsigned int size) {
|
||||
printf("%s:%s:%d EEPROM simulated by file..\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//printf("%s:%s:%d EEPROM simulated by file..\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
unsigned char checksum = 0;
|
||||
for(; size > 0; size--) {
|
||||
checksum = (checksum << 1) || (checksum >> 7);
|
||||
|
||||
@@ -29,4 +29,6 @@ void eeprom_put_char(unsigned int addr, unsigned char new_value);
|
||||
void memcpy_to_eeprom_with_checksum(unsigned int destination, char *source, unsigned int size);
|
||||
int memcpy_from_eeprom_with_checksum(char *destination, unsigned int source, unsigned int size);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,6 +37,8 @@ static void protocol_exec_rt_suspend();
|
||||
*/
|
||||
void protocol_main_loop()
|
||||
{
|
||||
printf("%s:%s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
// Perform some machine checks to make sure everything is good to go.
|
||||
#ifdef CHECK_LIMITS_AT_INIT
|
||||
if (bit_istrue(settings.flags, BITFLAG_HARD_LIMIT_ENABLE)) {
|
||||
|
||||
@@ -104,7 +104,7 @@ void write_global_settings()
|
||||
void settings_restore(uint8_t restore_flag) {
|
||||
if (restore_flag & SETTINGS_RESTORE_DEFAULTS) {
|
||||
settings = defaults;
|
||||
write_global_settings();
|
||||
write_global_settings();
|
||||
}
|
||||
|
||||
if (restore_flag & SETTINGS_RESTORE_PARAMETERS) {
|
||||
@@ -129,6 +129,7 @@ void settings_restore(uint8_t restore_flag) {
|
||||
eeprom_put_char(EEPROM_ADDR_BUILD_INFO , 0);
|
||||
eeprom_put_char(EEPROM_ADDR_BUILD_INFO+1 , 0); // Checksum
|
||||
}
|
||||
printf("%s:%s:%d settings_restore complete!!!..\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user