New ML support - w25x20cl spi external flash support
+fixed some messages +sec lang update test
This commit is contained in:
parent
70bb851c62
commit
c0946d8f04
15 changed files with 160 additions and 56 deletions
|
@ -50,7 +50,7 @@
|
||||||
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "WString.h"
|
//#include "WString.h"
|
||||||
|
|
||||||
#ifdef AT90USB
|
#ifdef AT90USB
|
||||||
#ifdef BTENABLED
|
#ifdef BTENABLED
|
||||||
|
|
|
@ -996,35 +996,95 @@ void erase_eeprom_section(uint16_t offset, uint16_t bytes)
|
||||||
|
|
||||||
#include "bootapp.h"
|
#include "bootapp.h"
|
||||||
|
|
||||||
void __test()
|
void __test(uint8_t lang)
|
||||||
{
|
{
|
||||||
|
uint8_t cnt = lang_get_count();
|
||||||
|
printf_P(PSTR("cnt=%d lang=%d\n"), cnt, lang);
|
||||||
|
if ((lang < 2) || (lang > cnt)) return;
|
||||||
|
|
||||||
cli();
|
cli();
|
||||||
boot_app_magic = 0x55aa55aa;
|
boot_app_magic = BOOT_APP_MAGIC;
|
||||||
boot_app_flags = BOOT_APP_FLG_USER0;
|
boot_app_flags = BOOT_APP_FLG_USER0;
|
||||||
boot_reserved = 0x00;
|
boot_reserved = lang << 4;
|
||||||
wdt_enable(WDTO_15MS);
|
wdt_enable(WDTO_15MS);
|
||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef W25X20CL
|
#ifdef W25X20CL
|
||||||
|
|
||||||
|
#define W25X20CL_BLOCK 1024
|
||||||
|
|
||||||
void upgrade_sec_lang_from_external_flash()
|
void upgrade_sec_lang_from_external_flash()
|
||||||
{
|
{
|
||||||
if ((boot_app_magic == 0x55aa55aa) && (boot_app_flags & BOOT_APP_FLG_USER0))
|
if ((boot_app_magic == BOOT_APP_MAGIC) && (boot_app_flags & BOOT_APP_FLG_USER0))
|
||||||
{
|
{
|
||||||
fprintf_P(lcdout, PSTR(ESC_2J ESC_H(1,1) "TEST %d"), boot_reserved);
|
uint8_t lang = boot_reserved >> 4;
|
||||||
boot_reserved++;
|
uint8_t state = boot_reserved & 0xf;
|
||||||
if (boot_reserved < 4)
|
|
||||||
|
fprintf_P(lcdout, PSTR(ESC_H(1,3) "lang=%1hhd state=%1hhx"), lang, state);
|
||||||
|
delay(1000);
|
||||||
|
state++;
|
||||||
|
boot_reserved = state | (lang << 4);
|
||||||
|
if (state < 15)
|
||||||
{
|
{
|
||||||
_delay_ms(1000);
|
|
||||||
cli();
|
cli();
|
||||||
wdt_enable(WDTO_15MS);
|
wdt_enable(WDTO_15MS);
|
||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
/* fprintf_P(lcdout, PSTR(ESC_2J "UPGRADE START"));
|
||||||
|
delay(1000);
|
||||||
|
fprintf_P(lcdout, PSTR(ESC_H(1,1) "lang=%hhd state=%hhd"), lang, state);
|
||||||
|
delay(1000);*/
|
||||||
|
/*
|
||||||
|
lang_table_header_t header;
|
||||||
|
uint32_t src_addr = 0x00000;
|
||||||
|
if (lang_get_header(lang, &header, &src_addr))
|
||||||
|
{
|
||||||
|
uint16_t dst_addr = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
|
||||||
|
uint16_t size = W25X20CL_BLOCK * state;
|
||||||
|
src_addr += size;
|
||||||
|
dst_addr += size;
|
||||||
|
state++;
|
||||||
|
boot_reserved = state | (lang << 4);
|
||||||
|
if (size < header.size)
|
||||||
|
{
|
||||||
|
fprintf_P(lcdout, PSTR(ESC_2J ESC_H(1,0) "Copying lang #%hhd" ESC_H(1,1) "size 0x%04x"), lang, size);
|
||||||
|
size = header.size - size;
|
||||||
|
if (size > W25X20CL_BLOCK) size = W25X20CL_BLOCK;
|
||||||
|
|
||||||
|
// delay(1000);
|
||||||
|
// cli();
|
||||||
|
// wdt_enable(WDTO_15MS);
|
||||||
|
// while(1);
|
||||||
|
cli();
|
||||||
|
w25x20cl_rd_data(src_addr, (uint8_t*)0x0800, 256);
|
||||||
|
bootapp_ram2flash(0x0800, dst_addr, 256);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// header.size - (4096*state);
|
||||||
|
|
||||||
|
fprintf_P(lcdout, PSTR(ESC_2J ESC_H(1,0) "Copying lang #%hhd" ESC_H(1,1) "state %hhd" ESC_H(1,2) "offs: %08lx" ESC_H(1,3) "remain %04x"), lang, state, offset, remain);
|
||||||
|
state++;
|
||||||
|
boot_reserved = state | (lang << 4);
|
||||||
|
if (state < 4)
|
||||||
|
{
|
||||||
|
_delay_ms(1000);
|
||||||
|
cli();
|
||||||
|
wdt_enable(WDTO_15MS);
|
||||||
|
while(1);
|
||||||
|
}*/
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
boot_app_flags &= ~BOOT_APP_FLG_USER0;
|
boot_app_flags &= ~BOOT_APP_FLG_USER0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DEBUG_W25X20CL
|
||||||
|
|
||||||
uint8_t lang_xflash_enum_codes(uint16_t* codes)
|
uint8_t lang_xflash_enum_codes(uint16_t* codes)
|
||||||
{
|
{
|
||||||
lang_table_header_t header;
|
lang_table_header_t header;
|
||||||
|
@ -1044,7 +1104,7 @@ uint8_t lang_xflash_enum_codes(uint16_t* codes)
|
||||||
printf_P(_n(" _lt_size = 0x%04x (%d)\n"), header.size, header.size);
|
printf_P(_n(" _lt_size = 0x%04x (%d)\n"), header.size, header.size);
|
||||||
printf_P(_n(" _lt_count = 0x%04x (%d)\n"), header.count, header.count);
|
printf_P(_n(" _lt_count = 0x%04x (%d)\n"), header.count, header.count);
|
||||||
printf_P(_n(" _lt_chsum = 0x%04x\n"), header.checksum);
|
printf_P(_n(" _lt_chsum = 0x%04x\n"), header.checksum);
|
||||||
printf_P(_n(" _lt_code = 0x%04x\n"), header.code);
|
printf_P(_n(" _lt_code = 0x%04x (%c%c)\n"), header.code, header.code >> 8, header.code & 0xff);
|
||||||
printf_P(_n(" _lt_resv1 = 0x%08lx\n"), header.reserved1);
|
printf_P(_n(" _lt_resv1 = 0x%08lx\n"), header.reserved1);
|
||||||
|
|
||||||
addr += header.size;
|
addr += header.size;
|
||||||
|
@ -1061,6 +1121,8 @@ void list_sec_lang_from_external_flash()
|
||||||
printf_P(_n("XFlash lang count = %hhd\n"), count);
|
printf_P(_n("XFlash lang count = %hhd\n"), count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif //DEBUG_W25X20CL
|
||||||
|
|
||||||
#endif //W25X20CL
|
#endif //W25X20CL
|
||||||
|
|
||||||
|
|
||||||
|
@ -1069,16 +1131,20 @@ void list_sec_lang_from_external_flash()
|
||||||
// are initialized by the main() routine provided by the Arduino framework.
|
// are initialized by the main() routine provided by the Arduino framework.
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
lcd_init();
|
||||||
|
fdev_setup_stream(lcdout, lcd_putchar, NULL, _FDEV_SETUP_WRITE); //setup lcdout stream
|
||||||
|
|
||||||
#ifdef NEW_SPI
|
#ifdef NEW_SPI
|
||||||
spi_init();
|
spi_init();
|
||||||
#endif //NEW_SPI
|
#endif //NEW_SPI
|
||||||
|
|
||||||
lcd_init();
|
|
||||||
fdev_setup_stream(lcdout, lcd_putchar, NULL, _FDEV_SETUP_WRITE); //setup lcdout stream
|
|
||||||
|
|
||||||
upgrade_sec_lang_from_external_flash();
|
|
||||||
|
|
||||||
lcd_splash();
|
lcd_splash();
|
||||||
|
|
||||||
|
if (w25x20cl_init())
|
||||||
|
upgrade_sec_lang_from_external_flash();
|
||||||
|
else
|
||||||
|
kill(_i("External SPI flash W25X20CL not responding."));
|
||||||
|
|
||||||
setup_killpin();
|
setup_killpin();
|
||||||
setup_powerhold();
|
setup_powerhold();
|
||||||
|
|
||||||
|
@ -1369,21 +1435,17 @@ void setup()
|
||||||
// If they differ, an update procedure may need to be performed. At the end of this block, the current firmware version
|
// If they differ, an update procedure may need to be performed. At the end of this block, the current firmware version
|
||||||
// is being written into the EEPROM, so the update procedure will be triggered only once.
|
// is being written into the EEPROM, so the update procedure will be triggered only once.
|
||||||
|
|
||||||
spi_setup(TMC2130_SPCR, TMC2130_SPSR);
|
|
||||||
puts_P(_n("w25x20cl init: "));
|
|
||||||
if (w25x20cl_ini())
|
|
||||||
{
|
|
||||||
uint8_t uid[8]; // 64bit unique id
|
|
||||||
w25x20cl_rd_uid(uid);
|
|
||||||
puts_P(_n("OK, UID="));
|
|
||||||
for (uint8_t i = 0; i < 8; i ++)
|
|
||||||
printf_P(PSTR("%02hhx"), uid[i]);
|
|
||||||
putchar('\n');
|
|
||||||
list_sec_lang_from_external_flash();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
puts_P(_n("NG!\n"));
|
|
||||||
|
|
||||||
|
#ifdef DEBUG_W25X20CL
|
||||||
|
W25X20CL_SPI_ENTER();
|
||||||
|
uint8_t uid[8]; // 64bit unique id
|
||||||
|
w25x20cl_rd_uid(uid);
|
||||||
|
puts_P(_n("W25X20CL UID="));
|
||||||
|
for (uint8_t i = 0; i < 8; i ++)
|
||||||
|
printf_P(PSTR("%02hhx"), uid[i]);
|
||||||
|
putchar('\n');
|
||||||
|
list_sec_lang_from_external_flash();
|
||||||
|
#endif //DEBUG_W25X20CL
|
||||||
|
|
||||||
lang_selected = eeprom_read_byte((uint8_t*)EEPROM_LANG);
|
lang_selected = eeprom_read_byte((uint8_t*)EEPROM_LANG);
|
||||||
if (lang_selected >= LANG_NUM)
|
if (lang_selected >= LANG_NUM)
|
||||||
|
@ -1393,12 +1455,13 @@ void setup()
|
||||||
}
|
}
|
||||||
lang_select(lang_selected);
|
lang_select(lang_selected);
|
||||||
|
|
||||||
|
//#ifdef DEBUG_SEC_LANG
|
||||||
|
|
||||||
uint16_t sec_lang_code = lang_get_code(1);
|
uint16_t sec_lang_code = lang_get_code(1);
|
||||||
printf_P(_n("SEC_LANG_CODE=0x%04x (%c%c)\n"), sec_lang_code, sec_lang_code >> 8, sec_lang_code & 0xff);
|
printf_P(_n("SEC_LANG_CODE=0x%04x (%c%c)\n"), sec_lang_code, sec_lang_code >> 8, sec_lang_code & 0xff);
|
||||||
|
|
||||||
#ifdef DEBUG_SEC_LANG
|
// lang_print_sec_lang(uartout);
|
||||||
lang_print_sec_lang(uartout);
|
//#endif //DEBUG_SEC_LANG
|
||||||
#endif //DEBUG_SEC_LANG
|
|
||||||
|
|
||||||
if (eeprom_read_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE) == 255) {
|
if (eeprom_read_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE) == 255) {
|
||||||
eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0);
|
eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0);
|
||||||
|
@ -2224,7 +2287,7 @@ void homeaxis(int axis, uint8_t cnt, uint8_t* pstep)
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
if (READ(Z_TMC2130_DIAG) != 0) { //Z crash
|
if (READ(Z_TMC2130_DIAG) != 0) { //Z crash
|
||||||
FORCE_HIGH_POWER_END;
|
FORCE_HIGH_POWER_END;
|
||||||
kill(MSG_BED_LEVELING_FAILED_POINT_LOW);
|
kill(_T(MSG_BED_LEVELING_FAILED_POINT_LOW));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif //TMC2130
|
#endif //TMC2130
|
||||||
|
@ -2240,7 +2303,7 @@ void homeaxis(int axis, uint8_t cnt, uint8_t* pstep)
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
if (READ(Z_TMC2130_DIAG) != 0) { //Z crash
|
if (READ(Z_TMC2130_DIAG) != 0) { //Z crash
|
||||||
FORCE_HIGH_POWER_END;
|
FORCE_HIGH_POWER_END;
|
||||||
kill(MSG_BED_LEVELING_FAILED_POINT_LOW);
|
kill(_T(MSG_BED_LEVELING_FAILED_POINT_LOW));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif //TMC2130
|
#endif //TMC2130
|
||||||
|
@ -5004,7 +5067,7 @@ Sigma_Exit:
|
||||||
setWatch();
|
setWatch();
|
||||||
break;
|
break;
|
||||||
case 112: // M112 -Emergency Stop
|
case 112: // M112 -Emergency Stop
|
||||||
kill("", 3);
|
kill(_n(""), 3);
|
||||||
break;
|
break;
|
||||||
case 140: // M140 set bed temp
|
case 140: // M140 set bed temp
|
||||||
if (code_seen('S')) setTargetBed(code_value());
|
if (code_seen('S')) setTargetBed(code_value());
|
||||||
|
@ -7387,7 +7450,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
|
||||||
|
|
||||||
if( (millis() - previous_millis_cmd) > max_inactive_time )
|
if( (millis() - previous_millis_cmd) > max_inactive_time )
|
||||||
if(max_inactive_time)
|
if(max_inactive_time)
|
||||||
kill("", 4);
|
kill(_n(""), 4);
|
||||||
if(stepper_inactive_time) {
|
if(stepper_inactive_time) {
|
||||||
if( (millis() - previous_millis_cmd) > stepper_inactive_time )
|
if( (millis() - previous_millis_cmd) > stepper_inactive_time )
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,12 +20,12 @@ void bootapp_print_vars()
|
||||||
void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size)
|
void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size)
|
||||||
{
|
{
|
||||||
cli();
|
cli();
|
||||||
boot_app_magic = 0x55aa55aa;
|
boot_app_magic = BOOT_APP_MAGIC;
|
||||||
boot_app_flags |= BOOT_APP_FLG_COPY;
|
boot_app_flags |= BOOT_APP_FLG_COPY;
|
||||||
uint16_t ui; for (ui = 0; ui < size; ui++)
|
uint16_t ui; for (ui = 0; ui < size; ui++)
|
||||||
{
|
{
|
||||||
uint8_t uc = ram_array[ui+rptr];
|
uint8_t uc = ram_array[ui+rptr];
|
||||||
if (pgm_readbyte(ui+fptr) & uc != uc)
|
if (pgm_read_byte(ui+fptr) & uc != uc)
|
||||||
{
|
{
|
||||||
boot_app_flags |= BOOT_APP_FLG_ERASE;
|
boot_app_flags |= BOOT_APP_FLG_ERASE;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#define BOOT_APP_FLG_USER0 0x80
|
#define BOOT_APP_FLG_USER0 0x80
|
||||||
|
|
||||||
|
#define BOOT_APP_MAGIC 0x55aa55aa
|
||||||
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -19,7 +19,12 @@
|
||||||
#define TMC2130_SPSR SPI_SPSR(TMC2130_SPI_RATE)
|
#define TMC2130_SPSR SPI_SPSR(TMC2130_SPI_RATE)
|
||||||
|
|
||||||
//W25X20CL configuration
|
//W25X20CL configuration
|
||||||
|
//pinout:
|
||||||
#define W25X20CL_PIN_CS 32
|
#define W25X20CL_PIN_CS 32
|
||||||
|
//spi:
|
||||||
|
#define W25X20CL_SPI_RATE 0 // fosc/4 = 4MHz
|
||||||
|
#define W25X20CL_SPCR SPI_SPCR(W25X20CL_SPI_RATE, 1, 1, 1, 0)
|
||||||
|
#define W25X20CL_SPSR SPI_SPSR(W25X20CL_SPI_RATE)
|
||||||
|
|
||||||
//LANG - Multi-language support
|
//LANG - Multi-language support
|
||||||
//#define LANG_MODE 0 // primary language only
|
//#define LANG_MODE 0 // primary language only
|
||||||
|
|
|
@ -97,10 +97,36 @@ uint8_t lang_get_count()
|
||||||
#endif //W25X20CL
|
#endif //W25X20CL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* offset)
|
||||||
|
{
|
||||||
|
if (lang == LANG_ID_PRI) return 0; //primary lang not supported for this function
|
||||||
|
#ifdef W25X20CL
|
||||||
|
if (lang == LANG_ID_SEC)
|
||||||
|
{
|
||||||
|
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
|
||||||
|
memcpy_P(header, ui, sizeof(lang_table_header_t)); //read table header from progmem
|
||||||
|
if (offset) *offset = ui;
|
||||||
|
return (header == LANG_MAGIC)?1:0; //return 1 if magic valid
|
||||||
|
}
|
||||||
|
uint32_t addr = 0x00000; //start of xflash
|
||||||
|
lang--;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
w25x20cl_rd_data(addr, header, sizeof(lang_table_header_t)); //read table header from xflash
|
||||||
|
if (header->magic != LANG_MAGIC) break; //break if not valid
|
||||||
|
if (offset) *offset = addr;
|
||||||
|
if (--lang == 0) return 1;
|
||||||
|
addr += header->size; //calc address of next table
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#else //W25X20CL
|
||||||
|
#endif //W25X20CL
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t lang_get_code(uint8_t lang)
|
uint16_t lang_get_code(uint8_t lang)
|
||||||
{
|
{
|
||||||
#ifdef W25X20CL
|
|
||||||
if (lang == LANG_ID_PRI) return LANG_CODE_EN; //primary lang = EN
|
if (lang == LANG_ID_PRI) return LANG_CODE_EN; //primary lang = EN
|
||||||
|
#ifdef W25X20CL
|
||||||
if (lang == LANG_ID_SEC)
|
if (lang == LANG_ID_SEC)
|
||||||
{
|
{
|
||||||
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
|
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
|
||||||
|
|
|
@ -108,6 +108,7 @@ extern uint8_t lang_select(uint8_t lang);
|
||||||
|
|
||||||
//get total number of languages (primary + all in xflash)
|
//get total number of languages (primary + all in xflash)
|
||||||
extern uint8_t lang_get_count();
|
extern uint8_t lang_get_count();
|
||||||
|
extern uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* offset);
|
||||||
extern uint16_t lang_get_code(uint8_t lang);
|
extern uint16_t lang_get_code(uint8_t lang);
|
||||||
extern const char* lang_get_name_by_code(uint16_t code);
|
extern const char* lang_get_name_by_code(uint16_t code);
|
||||||
|
|
||||||
|
|
|
@ -119,3 +119,4 @@ const char MSG_Z_MAX[] PROGMEM_N1 = "z_max: "; ////c=0 r=0
|
||||||
const char MSG_Z_MIN[] PROGMEM_N1 = "z_min: "; ////c=0 r=0
|
const char MSG_Z_MIN[] PROGMEM_N1 = "z_min: "; ////c=0 r=0
|
||||||
const char MSG_ZPROBE_OUT[] PROGMEM_N1 = "Z probe out. bed"; ////c=0 r=0
|
const char MSG_ZPROBE_OUT[] PROGMEM_N1 = "Z probe out. bed"; ////c=0 r=0
|
||||||
const char MSG_ZPROBE_ZOFFSET[] PROGMEM_N1 = "Z Offset"; ////c=0 r=0
|
const char MSG_ZPROBE_ZOFFSET[] PROGMEM_N1 = "Z Offset"; ////c=0 r=0
|
||||||
|
const char MSG_TMC_OVERTEMP[] PROGMEM_N1 = "TMC DRIVER OVERTEMP"; ////c=0 r=0
|
||||||
|
|
|
@ -116,3 +116,4 @@ extern const char MSG_Z_MAX[];
|
||||||
extern const char MSG_Z_MIN[];
|
extern const char MSG_Z_MIN[];
|
||||||
extern const char MSG_ZPROBE_OUT[];
|
extern const char MSG_ZPROBE_OUT[];
|
||||||
extern const char MSG_ZPROBE_ZOFFSET[];
|
extern const char MSG_ZPROBE_ZOFFSET[];
|
||||||
|
extern const char MSG_TMC_OVERTEMP[];
|
||||||
|
|
|
@ -832,7 +832,7 @@ static float analog2temp(int raw, uint8_t e) {
|
||||||
SERIAL_ERROR_START;
|
SERIAL_ERROR_START;
|
||||||
SERIAL_ERROR((int)e);
|
SERIAL_ERROR((int)e);
|
||||||
SERIAL_ERRORLNPGM(" - Invalid extruder number !");
|
SERIAL_ERRORLNPGM(" - Invalid extruder number !");
|
||||||
kill("", 6);
|
kill(PSTR(""), 6);
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
#ifdef HEATER_0_USES_MAX6675
|
#ifdef HEATER_0_USES_MAX6675
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "tmc2130.h"
|
#include "tmc2130.h"
|
||||||
#include "LiquidCrystal_Prusa.h"
|
#include "LiquidCrystal_Prusa.h"
|
||||||
#include "ultralcd.h"
|
#include "ultralcd.h"
|
||||||
|
#include "language.h"
|
||||||
#ifndef NEW_SPI
|
#ifndef NEW_SPI
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#else //NEW_SPI
|
#else //NEW_SPI
|
||||||
|
@ -386,7 +387,6 @@ bool tmc2130_wait_standstill_xy(int timeout)
|
||||||
|
|
||||||
void tmc2130_check_overtemp()
|
void tmc2130_check_overtemp()
|
||||||
{
|
{
|
||||||
const static char TMC_OVERTEMP_MSG[] PROGMEM = "TMC DRIVER OVERTEMP ";
|
|
||||||
static uint32_t checktime = 0;
|
static uint32_t checktime = 0;
|
||||||
if (millis() - checktime > 1000 )
|
if (millis() - checktime > 1000 )
|
||||||
{
|
{
|
||||||
|
@ -397,11 +397,11 @@ void tmc2130_check_overtemp()
|
||||||
tmc2130_rd(i, TMC2130_REG_DRV_STATUS, &drv_status);
|
tmc2130_rd(i, TMC2130_REG_DRV_STATUS, &drv_status);
|
||||||
if (drv_status & ((uint32_t)1 << 26))
|
if (drv_status & ((uint32_t)1 << 26))
|
||||||
{ // BIT 26 - over temp prewarning ~120C (+-20C)
|
{ // BIT 26 - over temp prewarning ~120C (+-20C)
|
||||||
SERIAL_ERRORRPGM(TMC_OVERTEMP_MSG);
|
SERIAL_ERRORRPGM(MSG_TMC_OVERTEMP);
|
||||||
SERIAL_ECHOLN(i);
|
SERIAL_ECHOLN(i);
|
||||||
for (int j = 0; j < 4; j++)
|
for (int j = 0; j < 4; j++)
|
||||||
tmc2130_wr(j, TMC2130_REG_CHOPCONF, 0x00010000);
|
tmc2130_wr(j, TMC2130_REG_CHOPCONF, 0x00010000);
|
||||||
kill(TMC_OVERTEMP_MSG);
|
kill(MSG_TMC_OVERTEMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5657,11 +5657,13 @@ void lcd_confirm_print()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void __test();
|
extern void __test(uint8_t lang);
|
||||||
|
|
||||||
static void lcd_test_menu()
|
static void lcd_test_menu()
|
||||||
{
|
{
|
||||||
__test();
|
__test(3);
|
||||||
|
lcd_update_enable(true);
|
||||||
|
lcd_return_to_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lcd_main_menu()
|
static void lcd_main_menu()
|
||||||
|
@ -5833,7 +5835,7 @@ static void lcd_main_menu()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MENU_ITEM(submenu, _i("Support"), lcd_support_menu);////MSG_SUPPORT c=0 r=0
|
MENU_ITEM(submenu, _i("Support"), lcd_support_menu);////MSG_SUPPORT c=0 r=0
|
||||||
// MENU_ITEM(submenu, _i("Test"), lcd_test_menu);////MSG_SUPPORT c=0 r=0
|
MENU_ITEM(submenu, _i("Test"), lcd_test_menu);////MSG_SUPPORT c=0 r=0
|
||||||
|
|
||||||
END_MENU();
|
END_MENU();
|
||||||
|
|
||||||
|
|
|
@ -149,6 +149,7 @@
|
||||||
|
|
||||||
//#define DEBUG_BUILD
|
//#define DEBUG_BUILD
|
||||||
//#define DEBUG_SEC_LANG //secondary language debug output at startup
|
//#define DEBUG_SEC_LANG //secondary language debug output at startup
|
||||||
|
//#define DEBUG_W25X20CL //debug external spi flash
|
||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
//#define _NO_ASM
|
//#define _NO_ASM
|
||||||
#define DEBUG_DCODES //D codes
|
#define DEBUG_DCODES //D codes
|
||||||
|
|
|
@ -36,17 +36,18 @@
|
||||||
|
|
||||||
//#define _SPI_TX swspi_tx
|
//#define _SPI_TX swspi_tx
|
||||||
//#define _SPI_RX swspi_rx
|
//#define _SPI_RX swspi_rx
|
||||||
#define _SPI_TX(b) spi_txrx(b)
|
#define _SPI_TX(b) spi_txrx(b)
|
||||||
#define _SPI_RX() spi_txrx(0xff)
|
#define _SPI_RX() spi_txrx(0xff)
|
||||||
|
|
||||||
|
|
||||||
int w25x20cl_mfrid_devid(void);
|
int w25x20cl_mfrid_devid(void);
|
||||||
|
|
||||||
|
|
||||||
int8_t w25x20cl_ini(void)
|
int8_t w25x20cl_init(void)
|
||||||
{
|
{
|
||||||
PIN_OUT(W25X20CL_PIN_CS);
|
PIN_OUT(W25X20CL_PIN_CS);
|
||||||
_CS_HIGH();
|
_CS_HIGH();
|
||||||
|
W25X20CL_SPI_ENTER();
|
||||||
if (!w25x20cl_mfrid_devid()) return 0;
|
if (!w25x20cl_mfrid_devid()) return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,20 +6,21 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
#define W25_STATUS_BUSY 0x01
|
#define W25X20CL_STATUS_BUSY 0x01
|
||||||
#define W25_STATUS_WEL 0x02
|
#define W25X20CL_STATUS_WEL 0x02
|
||||||
#define W25_STATUS_BP0 0x04
|
#define W25X20CL_STATUS_BP0 0x04
|
||||||
#define W25_STATUS_BP1 0x08
|
#define W25X20CL_STATUS_BP1 0x08
|
||||||
#define W25_STATUS_TB 0x20
|
#define W25X20CL_STATUS_TB 0x20
|
||||||
#define W25_STATUS_SRP 0x80
|
#define W25X20CL_STATUS_SRP 0x80
|
||||||
|
|
||||||
|
#define W25X20CL_SPI_ENTER() spi_setup(W25X20CL_SPCR, W25X20CL_SPSR)
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif //defined(__cplusplus)
|
#endif //defined(__cplusplus)
|
||||||
|
|
||||||
|
|
||||||
extern int8_t w25x20cl_ini(void);
|
extern int8_t w25x20cl_init(void);
|
||||||
extern void w25x20cl_enable_wr(void);
|
extern void w25x20cl_enable_wr(void);
|
||||||
extern void w25x20cl_disable_wr(void);
|
extern void w25x20cl_disable_wr(void);
|
||||||
extern uint8_t w25x20cl_rd_status_reg(void);
|
extern uint8_t w25x20cl_rd_status_reg(void);
|
||||||
|
|
Loading…
Reference in a new issue